Hi, Im trying out Mathematica to connect our shared library to Mathematika but I have problems during running functions in the shared Library. So I started with a test shared library. Some parts work fine so far. At first what worked:
1. AppendTo[$LibraryPath, ToFileName["/slowfs/lithop4-nb-2/egger/Mathematica/Tests"]];
2. LibraryLoad["libtestlib"]
3. INTTEST2 = LibraryFunctionLoad["libtestlib", "Inttest2", {Integer, Integer}, Integer]
That worked so far. But running
INTTEST2[10, 101]
returned an error message:
LibraryFunction::rterr: An error with return code -1429266942 was encountered evaluating the function Inttest2. >>
I used Red Hat Enterprise Linux Client release 5.7 (Tikanga) and gcc version 4.1.2 20080704 (Red Hat 4.1.2-51). Building the test shared library was done by
gcc -c -g -fPIC testlib.cpp -I.
gcc -shared -o libtestlib.so testlib.o
The console output from my shared library was:
Inttest2 parameter 1 is -1429266944 and parameter 2 is 2
Inttest parameter is -1429249280
I added two attachments testlibheader.txt that contains the header file testlib.h and testlibsource.txt in unix text format.
The interesting lines of the header are:
void Inttest1(int iTest);
int Inttest2(int iTest, int iTest2);
and of the cpp file are:
void Inttest1(int iTest) { std::cerr << "Inttest parameter is " << iTest << std::endl; }
long Inttest2(long iTest, long iTest2) { std::cerr << "Inttest2 new parameter 1 is " << iTest << " and parameter 2 is " << iTest2 << std::endl; long iSum = iTest + iTest2; return iSum; }
I hope you can help me with that problem. Kind regards, Roland
Attachments: