gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnucap-devel] CMake, file extensions


From: Richard Crozier
Subject: Re: [Gnucap-devel] CMake, file extensions
Date: Mon, 13 Feb 2017 16:39:29 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

On 13/02/17 16:21, Felix Salfelder wrote:
On Mon, Feb 13, 2017 at 10:59:27AM +0000, Richard Crozier wrote:
You could do something similar to what matlab does. It uses custom suffix
for compiled shared libraries (mex files) but with a platform specific
extension (e.g. .mexw64 for win 64, .mexa64 for linux 64 bit etc.). Under
the hood they are just shared libraries.

with this, i understand that in matlab-ui you do load("module"), and it
then (roughly) calls dlopen("module" + ".mexa64").


With Matlab being proprietary I can't say exactly what happens, but 'roughly' yes. You write a special entry function to your C or C++ code which includes a header file mex.h, and matlab compiles this for you into a shared library (just by passing the appropriate flags to normal compilers). In Matlab you then call it like you would any normal function without any suffix. In their case everything gets compiled statically into the shared library though so it is portable.

Octave (a free matlab alternative) also supports mex files but they've not gone down the route of different file extensions (a mistake in my opinion), but they might have code to copy.

what if you wanted to dlopen just "module.so"? (would that be
useful/worth supporting?)


I don't know, I don't have a strong opinion on this.

The advantage of this approach is that they can be on the Maltab search path
and easily found without mixing up with other shared libraries and different
platforms versions can coexist.

indeed, with just .so/.dll/.dylib, we will not be able to have both
32bit and 64bit libraries in one directory... i totally see the use
case.

instead of using md.h, we should add a configure flag for that
extension, so it will properly end up in the makefiles *and* in
c_attach. then it can be anything, and also work for future whatever
os/arch/abi combinations.

thanks for sharing
felix


Glad you found it useful!

Richard

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]