Re: MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'
- To: mathgroup at smc.vnet.net
- Subject: [mg114172] Re: MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'
- From: Klemen Dovrtel <klemen_dovrtel at yahoo.com>
- Date: Fri, 26 Nov 2010 05:27:20 -0500 (EST)
Thank you! Now it linked with no problem and the demo works fine :) Regards Klemen --- On Thu, 11/25/10, Patrick Scheibe <pscheibe at trm.uni-leipzig.de> wrote: > From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de> > Subject: Re: [mg114140] MathLink - Linux - Calling the Kernel from Extern= al Program - undefined reference to `shm_open' > To: "Klemen Dovrtel" <klemen_dovrtel at yahoo.com> > Cc: mathgroup at smc.vnet.net > Date: Thursday, November 25, 2010, 1:05 PM > 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/mathlin= k/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; > > > > printf( "Enter two integers:\n\t" > ); > > scanf( "%d %d", &i, &j); > > > > env == MLInitialize(NULL); > > if(env ==== NULL) return 1; > > lp == MLOpen(argc, argv); > > if(lp ==== NULL) return 1; > > > > /* Send Plus[i, j] */ > > MLPutFunction(lp, "Plus", 2); > > MLPutInteger(lp, > i); > > MLPutInteger(lp, > j); > > MLEndPacket(lp); > > > > /* skip any packets before the > first ReturnPacket */ > > while (MLNextPacket(lp) !== > RETURNPKT) MLNewPacket(lp); > > > > /* inside the ReturnPacket we > expect an integer */ > > MLGetInteger(lp, &sum); > > > > 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/Develope= rKit/Linux/CompilerAdditions" > "-I/usr/include/sys/" > > gcc -o ./Debug/mathematica1 ./Debug/main.o "-L." > "-L/usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/Develope= rKit/Linux/CompilerAdditions" > -lML32i3 -lML32i3 > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `shm_open' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `sem_init' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `sem_unlink' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `sem_close' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `sem_destroy' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `shm_unlink' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `pthread_create' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `sem_post' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `sem_trywait' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `sem_open' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/Linux/CompilerAdditions/libML32i3.so: > undefined reference to `sem_wait' > > > /usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKi= t/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 > > > > > > > > > > > > > > > > > > > > > >