CSLearner
CSLearner

Reputation: 11

/usr/../libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ...)

I have been stuck on this problem for several weeks and been looking around on Internet for solution but so far not so good...

So I have a program written by someone else and I try to compile it in Matlab to make it work. My computer is Red-hat enterprise Linux workstation (64 bits) with gcc 4.4.3 and Matlab 2011b installed. The gcc is compatible with my Matlab (http://www.mathworks.com/support/compilers/R2011b/glnxa64.html).

The compilation works fine (I mean, no error message occurs in Matlab command window). But after compilation, every time when I use a specific function from the compilation (it's call "mexLasso"), it will show up errors like this:

***Invalid MEX-file '/usr/local/matlab_R2011b/toolbox/spams-matlab/build/mexLasso.mexa64': /usr/local/matlab_R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/local/matlab_R2011b/toolbox/spams-matlab/build/mexLasso.mexa64)

Error in test (line 24) alpha=mexLasso(X,D,param);*

So I type "strings /usr/lib/libstdc++.so.6 | grep GLIBC" in the terminal, and I found the "GLIBCXX_3.4.11" is actually in it.

I've been using Linux and gcc stuff for only several months...so there are still a lot of things I don't understand. It will be of great help if you can explain it in detail. Thanks!!

%% More detail: I got these programs on machine learning from http://spams-devel.gforge.inria.fr/downloads.html. The wierd thing is, after compilation, other functions in that package works fine (such as "mexTrainDL").

Upvotes: 1

Views: 21808

Answers (4)

Urdojo
Urdojo

Reputation: 11

A simple solution from this page ( http://ubuntuforums.org/showthread.php?t=808045 ) that worked for me. Go to the matlab directory where libstdc++.so.6 and libgcc_s.so.1 are stored. In my case, this was:

cd /usr/local/MATLAB/MATLAB_Production_Server/R2015a/sys/os/glnxa64

Then rename libstdc++.so.6 and libgcc_s.so.1:

sudo mv libstdc++.so.6 libstdc++.so.6.orig
sudo mv libgcc_s.so.1 libgcc_s.so.1.orig

That's it!

Upvotes: 1

Yantao Xie
Yantao Xie

Reputation: 12906

The solution prompted by @whjiang works but have two limits:

  1. You may be required a sudo privilege to change the library symbol link.
  2. The change is global and can affect all users

So there is another.

As explained by this answer from MATLAB Central, the problem is caused by Matlab:

Matlab internally changes the LD_LIBRARY_PATH to prefer <MatlabPATH >/sys/os/<ARCH>

and the <MatlabPATH>/sys/os/libstdc++.so.6 is out of date.

The solution is set LD_PRELOAD when calling Matlab like this,

env LD_PRELOAD=/usr/lib/libstdc++.so.6  <MatlabPATH>/bin/matlab -desktop

The path of libstdc++.so.6 my be different from os to os. For example, on my LMDE2, the path is /usr/lib/x86_64-linux-gnu/libstdc++.so.6.

Upvotes: 5

whjiang
whjiang

Reputation: 11

Here is an solution:

sudo ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 /usr/local/MATLAB/R2011b/bin/glnxa64/libstdc++.so.6

explanation and reference: http://fantasticzr.wordpress.com/2013/05/29/matlab-error-libstdc-so-version-glibcxx_3-4-15-not-found/

Upvotes: 1

Jonathan Wakely
Jonathan Wakely

Reputation: 171373

This is answered in the libstdc++ FAQ: http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_paths

Upvotes: 2

Related Questions