I'm trying to find out the way to use c-functions in Mathematica (I'm using 14 version) on OS X 10.10.
For example I've got this lines of code:
#include <stdio.h>
double helloWorld(double a) {
return 2 * a;
}
Then I've tried to make a shared library like this:
gcc -dynamiclib -o mylib.dylib hello.c
After that I'm trying to load this function in mathematica:
LibraryFunctionLoad["~/term/mylib.dylib", "helloWorld", {Real}, Real];
But mathematica tells me that it cannot load my function
LibraryFunction::libload: The function helloWorld was not loaded from the file ~/term/mylib.dylib. >>
Is anyone has clue how to make this things work?
0000000000000f70 T _helloWorld U dyld_stub_binder
– Alex Nov 13 '14 at 09:24LibraryFunctionLoadis meant to be used only with functions specifically written for LibraryLink. If you are going to use LibraryLink, you will need to create a LibraryLink-compatible wrapper for whatever you need to call. There are other methods than LibraryLink for calling C functions, all described in the thread I linked. – Szabolcs Nov 21 '14 at 20:03