# MathLink library and undefined references

I am trying to use C++ programs through MathLink in my notebooks, but I cannot compile successfully the simple programs included in Mathematica.

I do not have a specific question, I am just looking for guidance.

$Version$SystemID "9.0 for Linux x86 (64-bit) (November 20, 2012)" "Linux-x86-64"

My operating system is Linux Mint 17.3 Cinnamon 64-bit.

Step by step, what I am trying to do is the following:

cd $InstallationDirectory/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/ mcc -o addtwo ../MathLinkExamples/addtwo.c ../MathLinkExamples/addtwo.tm Since I am trying to compile from the directory where the libraries and header (mathlink.h) is, I think it should work (I am no C expert either). I've also tried copying the addtwo.c and addtwo.tm files in the "CompilerAdditions" folder and run everything from there with the same results. I get the following errors $InstallationDirectory/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/libML64i3.so: undefined reference to 'shm_open' (*more undefined references, see below*) collect2: error: ld returned 1 exit status

The easiest way to see what libraries are required is to let Mathematica compile it and look at the commandline. First, locate the two required files addtwo.tm and addtwo.c. This might be a bit different on your system:

file = FileNames["addtwo.*", {\$InstallationDirectory}, Infinity][[5 ;; 6]]



After that, just try:

Needs["CCompilerDriver"];

-l"ML64i4" -lm -lpthread -lrt -lstdc++ -ldl -luuid
`