GLIBCXX not found when compiling vtk example under

2019-04-09 17:59发布

问题:

I have been trying to follow this example for compiling vtk in MATLAB using mex, on an Ubuntu 11.10. The mex command I used is as follows:

mex -I/usr/include/vtk-5.6 vtk_file.cpp -L/usr/lib/ -lvtkFiltering -lvtkRendering -lvtkCommon

After compilation I have a .mexa64 file.

However, when I try to run the file I end up with the following error:

Invalid MEX-file '/home/bill/Documents/MATLAB/vtk/vtk_file.mexa64': 
/usr/local/MATLAB/R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.11' not found (required by /usr/lib/libvtkFiltering.so.5.6)

How can I ensure that glibcxx is found? I would have assumed that it would be included by default in the compilation.

回答1:

Matlab uses its own glibc librarires, and it's often a big mess because of that.

To solve that problem you should first try to ensure that matlab use a supported version of gcc. Do you get a warning about that when you compile?

If you are sudoer, you can also "force" matlab to use the standard glibc, by doing something like that (I did it, and it works fine):

cd /usr/local/MATLAB/R2011a/sys/os/glnxa64
sudo mkdir old
sudo mv libstdc++.so.6* old
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6 

Many people complain about that on the internet, there are different solutions, if those two ones don't work.



标签: c++ glibc mex vtk