博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

libstdc++.so.6: version `GLIBCXX_3.4.11' not found 错误及解决

Posted on 2011-10-14 18:05  编著人  阅读(14167)  评论(0编辑  收藏  举报

我在网上下载了一段Matlab结合mex(C转成)实现的图像分割的程序,运行环境是Linux 64 + Matlab。

运行时报错:

/home/LinuxProg/Matlab/bin/glnxa64/http://www.cnblogs.com/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found

完整:

Invalid MEX-file '/home/zhang/work/BSR/grouping/lib/buildW.mexa64':
/usr/local/MATLAB/R2011b/bin/glnxa64/http://www.cnblogs.com/sys/os/glnxa64/libstdc++.so.6: version
`GLIBCXX_3.4.11' not found (required by /home/zhang/work/BSR/grouping/lib/buildW.mexa64)

下面总结一下我的解决过程:

首先,将MATLAB~/sys/os/glnxa64/libstdc++.so.6,改名为libstdc++.so.6_backup

sudo mv libstdc++.so.6 libstdc++.so.6_backup

(居然直接就能调通了20111019)

0. 将系统目录下/usr/lib/libstdc++.so.6复制到应用程序的库目录替换,如:这里复制到MATLAB_Path/sys/os/glnxa64/中。

博客:

http://blog.sina.com.cn/s/blog_6cf6b58d0100q0r2.html

给出的方法,我试了不行。原因我猜想是因为简单的复制改变了文件的指向,无法指向目标文件。

1. rm MATLAB_Path/sys/os/glnxa64/libstdc++.so.6

我试了,没成功。但是其它方法中的两篇文章都进行了实践,成功了。

2. 博客:libstdc++.so.6:version ‘GLIBCXX_3.4.**’not found

http://yq000cn.blog.163.com/blog/static/14369070201171653016852/

给出了文件libstdc++.so.6的查看方法:

$strings $MATLAB_Path/sys/os/glnxa64/libstdc++.so.6|grep "GLIBC"
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBC_2.1.3
GLIBC_2.2
GLIBC_2.3
GLIBC_2.0
GLIBC_2.1
GLIBCXX_FORCE_NEW

Linux:

$strings /usr/lib/libstdc++.so.6|grep "GLIBC"
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBC_2.0
GLIBC_2.3
GLIBC_2.1
GLIBC_2.1.3
GLIBC_2.3.2
GLIBC_2.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

所以做如下操作:

让MATLAB的libstdc++.so 软链接指向Linux的库文件

$ln –s /usr/iib/libstdc++.so.6 $MATLAB_Path/sys/os/glnxa64/libstdc++.so.6

搞定!

其它的2个网页,对1和2都进行了实践,但操作过程不够详细

1. 网页:

http://code.google.com/p/b-tk/issues/detail?id=8

This problem is due to the embedded libstc++ dynamic library in Matlab. Instead of using the library in /usr/lib, Matlab forces to use its own, and then has an incompatibility with BTK libraries linked to /usr/lib/listdc++.so.6.

给出的分析。文中实现1和2两种方法都获得了成功。对于1方法的解释:maybe it should be automatically moved from CMake during the installation step.

2. 论坛:

https://bbs.archlinux.org/viewtopic.php?id=86809

实践了1和2两种方法,都获得了成功,但细节不是很清楚。对1成功的解释:

Going to $MATLABROOT/sys/os/glnxa64 and moving libstdc++* and libgcc_s* out of the way (no need to link, it'll automatically look for system versions) is just part of the puzzle.