在编译mex下的vtk示例时找不到GLIBCXX [英] GLIBCXX not found when compiling vtk example under mex
问题描述
我一直试图按照这个例子在MATLAB中使用mex编译vtk,在Ubuntu 11.10上。我使用的mex命令如下:
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
编译后我有一个 .mexa64
文件。
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)
如何确保找到glibcxx?我会假设它将被默认包含在编译中。
How can I ensure that glibcxx is found? I would have assumed that it would be included by default in the compilation.
推荐答案
Matlab使用自己的glibc库,
Matlab uses its own glibc librarires, and it's often a big mess because of that.
为了解决这个问题,你应该首先尝试确保matlab使用支持的gcc版本。你在编译时会得到一个警告吗?
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?
如果你是sudoer,你也可以强制matlab使用标准的glibc,我做了,它工作正常):
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.
这篇关于在编译mex下的vtk示例时找不到GLIBCXX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!