MathLink binaries are expected to be run from within the Wolfram Language Kernel (e.g. Mathematica), so you'll see the binaries looking for some of the libraries contained in the $InstallationDirectory
. These MathLink examples are providing an interface for the kernel to run the C code. The proper way to use them is to load them within the Kernel with Install
.
SetDirectory[$InstallationDirectory <>
"/SystemFiles/Links/MathLink/DeveloperKit/" <> $SystemID <>
"/PrebuiltExamples/"];
link = Install["addtwo"];
AddTwo[1,2]
You can read more about this process in the documentation for Install and our documentation on MathLink/WSTP.
In general, you don't want to be modifying the system library paths to load non-standard library directories. If you really wanted to run with the Wolfram Language's libraries, you could just start a binary like this:
LD_LIBARY_PATH=/opt/Wolfram/WolframEngine/10.0/SystemFiles/Libraries/Linux-ARM/:$LD_LIBRARY_PATH ./my_binary