I work on a mac M1 with MacOS Sonoma and i use Mathematica 12.3.1 and 14.0
I wanted to ask if there is a way to load a .dylib library on Mac with Mathematica, which was compiled without using the Wolfram library (LibraryFunctionLoad) and without having to compile it with Mathematica (CreateLibrary)?
On Windows, I found that there is something called DefineDLLFunction which seems to work for loading .dll files, but I haven’t been able to make it work with .dylib files on macOS.
I use LibraryFunctionLoad and CreateLibrary already but it force me to put wolfram library in my C++ code and i would want to avoid that if possible
Thanks !
MTensors
). Then you combile this wrapper withCreateLibrary
and include the according linker commands with the optionLinkerOptions -> {"-l<library name>}
. You might also have to provide the path to that library with theLibraryDirectories
and the path to the included header files with theIncludeDirectories
. $\endgroup$extern "C"
and__attribute__((visibility("default")))
. You don't necessarily need the Mathematica data types. If the C++ library has a C library interface already you may not have to do this, but otherwise, function names end up mangled in C++. However, even then you could still find those name mangled functions and call those if the signature types are simple ones. $\endgroup$Mathematica
uses to something that the library can understand: standard C types and pointers to such. $\endgroup$