MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114140] MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'
  • From: Klemen Dovrtel <klemen_dovrtel at yahoo.com>
  • Date: Thu, 25 Nov 2010 05:56:05 -0500 (EST)

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;
	
	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/DeveloperKit/Linux/CompilerAdditions" "-I/usr/include/sys/" 
gcc -o ./Debug/mathematica1 ./Debug/main.o  "-L." "-L/usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit/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








      


  • Prev by Date: Re: FinancialDerivative Ver 8 (Bug maybe)
  • Next by Date: How to add a LegendLabel to a Chartlegends in BarChart
  • Previous by thread: Re: FinancialDerivative Ver 8 (Bug maybe)
  • Next by thread: Re: MathLink - Linux - Calling the Kernel from External Program - undefined reference to `shm_open'