Trouble compiling Mex files, "standard C libraries not found."

10 views (last 30 days)
I'm running Ubuntu and Matlab R2011b, and am trying to get a kdtree implementation to run in Matlab. (see here: <http://www.mathworks.com/matlabcentral/fileexchange/21512). Upon extracting, I add the folder to my run path, navigate to it in Matlab, and manually run the mex command on each file -
mex kdtree_build.cpp mex kdtree_delete.cpp etc.
Attempting to run the resulting mex files, however, gives me the error -
Invalid MEX-file '/home/alex/workspace/Daubechies/MatlabToolboxes/kdtree/kdtree_build.mexglx': /usr/local/MATLAB/R2011b/bin/glnx86/../../sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.15' not found.
This seems odd, as if I navigate to that folder, the libstdc++.so.6 file is in fact there. Any thoughts on what is going wrong and how to fix it?

Answers (3)

Kaustubha Govind
Kaustubha Govind on 19 Mar 2012
This might help.

Bryan
Bryan on 31 May 2012
The problem is not with finding libstdc++.so.6, but rather with the symbol versions included in the MATLAB supplied libraries. One solution is to make sure you are using a compatible compiler version. Attempting to use a newer compiler will likely introduce dynamic links to newer symbol versions that would be fine using the gcc supplied libraries (ie at compile time), but fail using the MATLAB supplied libraries (ie at run time).
See also this post

Ken Atwell
Ken Atwell on 3 Jun 2012
I would be tempted to try removing the MathWorks-supplied libraries from the search path inside of MATLAB:
setenv('LD_LIBRARY_PATH','');
mex ...
Does that help? Even if you manage build, your MEX-File may crash because you'll be linking against a C++ library that is different than the one that MATLAB itself was linked against (side effect are unpredictable in this situation). If stability is a problem, see Bryan's answer.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!