Re: MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'
- To: mathgroup at smc.vnet.net
- Subject: [mg114163] Re: MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'
- From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
- Date: Thu, 25 Nov 2010 07:07:30 -0500 (EST)
- References: <201011251056.FAA21772@smc.vnet.net>
Hi, you forgot to linke the right libraries -lm -lpthread -lrt as described in the MathLink tutorial tutorial/MathLinkDeveloperGuide-UnixOverview Cheers Patrick On Nov 25, 2010, at 11:56 AM, Klemen Dovrtel wrote: > Hello everybody, > > I would like to test a simple program i found in a MathLink tutorial = (http://www.edenwaith.com/development/tutorials/mathlink/ML_Tut.pdf). I = added the path to Mathematica libs and headers, but when i compile the = code, i get the "undefined reference to `shm_open'" error (and some = other errors). Any idea why is that? I searched the Archives and I = couldn't find such problem. > > I tried to include the shm.h header i found (/usr/include/bits/shm.h, = /usr/include/linux/shm.h, /usr/include/sys/shm.h), but no luck. > > I am using Ubuntu 10.04 and Mathematica 7. > > Best Regards > Klemen > > > ------------------------------------------------------------------ > CODE > > #include <stdio.h> > #include "mathlink.h" > #include <shm.h> > > > int main(int argc, char * argv[ ]) > { > int i, j, sum; > MLINK lp; > int pkt; > MLEnvironment env; > =09 > printf( "Enter two integers:\n\t" ); > scanf( "%d %d", &i, &j); > =09 > env = MLInitialize(NULL); > if(env == NULL) return 1; > lp = MLOpen(argc, argv); > if(lp == NULL) return 1; > =09 > /* Send Plus[i, j] */ > MLPutFunction(lp, "Plus", 2); > MLPutInteger(lp, i); > MLPutInteger(lp, j); > MLEndPacket(lp); > =09 > /* skip any packets before the first ReturnPacket */ > while (MLNextPacket(lp) != RETURNPKT) MLNewPacket(lp); > =09 > /* inside the ReturnPacket we expect an integer */ > MLGetInteger(lp, &sum); > =09 > printf( "sum = %d\n", sum); > MLClose(lp); > MLDeinitialize(env); > return 0; > } > > ------------------------------------------------------------------ > COMPILER ERRORS > > ----------Build Started-------- > /bin/sh -c '"make" -j 2 -f "math_wsp.mk"' > ----------Building project:[ mathematica1 - Debug ]---------- > make[1]: Entering directory `/home/klemen/c++/math' > make[1]: Leaving directory `/home/klemen/c++/math' > make[1]: Entering directory `/home/klemen/c++/math' > gcc -c "/home/klemen/c++/math/main.c" -g -o ./Debug/main.o "-I." = "-I." = "-I/usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/Developer= Kit/Linux/CompilerAdditions" "-I/usr/include/sys/" > gcc -o ./Debug/mathematica1 ./Debug/main.o "-L." = "-L/usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/Developer= Kit/Linux/CompilerAdditions" -lML32i3 -lML32i3 > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to `shm_open' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to `sem_init' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to = `sem_unlink' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to = `sem_close' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to = `sem_destroy' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to = `shm_unlink' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to = `pthread_create' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to `sem_post' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to = `sem_trywait' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to `sem_open' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to `sem_wait' > = /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit= /Linux/CompilerAdditions/libML32i3.so: undefined reference to = `pthread_join' > collect2: ld returned 1 exit status > make[1]: *** [Debug/mathematica1] Error 1 > make[1]: Leaving directory `/home/klemen/c++/math' > make: *** [All] Error 2 > ----------Build Ended---------- > 0 errors, 0 warnings > > > > > > > > > >
- References:
- MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'
- From: Klemen Dovrtel <klemen_dovrtel@yahoo.com>
- MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'