未找到 GLIBCXX_3.4.9
我有一个关于 libstdc++.so
的问题。
我安装了新版本的 gcc 并尝试编译 C++ 代码。编译工作正常,但是当我尝试执行二进制文件(m5.opt
是它的名称)时,出现以下错误:
build/ALPHA_SE/m5.opt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by build/ALPHA_SE/m5.opt).
我需要替换 libstdc++.so
?如果是的话,我在哪里可以下载我想要的版本?在 GCC 网站上,他们说 libstdc++ 现在是 gcc 的一部分。
详细
海湾合作委员会: 我以前有gcc 4.1.2,但我下载了gcc 4.2.4。从解压的 gcc 目录中,我执行了 ./configure
;制作; sudo make install`。 当我尝试使用gcc或g++编译时,它的默认版本仍然是4.1.2。为了克服这个问题,我替换了一些链接:
mv /usr/bin/gcc /usr/bin/gcc_bak
ln -s /usr/local/bin/gcc gcc
mv /usr/bin/g++ /usr/bin/g++_bak
ln -s /usr/local/bin/g++ g++
GLIBC(++) -- libstdc++:
/usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.8
/usr/local/lib/libstdc++.so -> libstdc++.so.6.0.9
/lib/libc.so.6 -> libc-2.5.so -> libc-2.5.so
Linux-version: uname -a
给出:
Linux madmax 2.6.18-128.4.1.el5 #1 SMP Tue Aug 4 12:51:10 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
I have a problem concerning libstdc++.so
.
I installed a new version of gcc and tried to compile C++ code. The compiling worked, but when I try to execute the binary (m5.opt
is its name) I've got the following error:
build/ALPHA_SE/m5.opt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by build/ALPHA_SE/m5.opt).
Do I need to replace libstdc++.so
? And if so, where can I download the version I want? On the GCC-website they say libstdc++ is a part of gcc now.
Details
GCC:
I had gcc 4.1.2 before, but I downloaded gcc 4.2.4. From the untarred gcc-directory I executed ./configure
; make; sudo make install`.
When I tried to use gcc or g++ to compile, it's default version was still 4.1.2. To overcome this I replaced some links:
mv /usr/bin/gcc /usr/bin/gcc_bak
ln -s /usr/local/bin/gcc gcc
mv /usr/bin/g++ /usr/bin/g++_bak
ln -s /usr/local/bin/g++ g++
GLIBC(++) -- libstdc++:
/usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.8
/usr/local/lib/libstdc++.so -> libstdc++.so.6.0.9
/lib/libc.so.6 -> libc-2.5.so -> libc-2.5.so
Linux-version:uname -a
gives:
Linux madmax 2.6.18-128.4.1.el5 #1 SMP Tue Aug 4 12:51:10 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题在于您错误地构建了新的
GCC
:在 Linux 上您应该使用默认安装前缀是
/usr/local
,这就是make install
的原因code> 将gcc
和g++
二进制文件放入/usr/local/bin
等。现在发生的情况是,您使用以下命令进行编译和链接新的(符号链接的)
GCC 4.2.4
,但在运行时您的程序绑定到旧的/usr/lib64/libstdc++.so.6
(版本 6.0.8,而不是所需的 6.0.9)。您可以通过运行ldd build/ALPHA_SE/m5.opt
来确认:您应该看到它使用/usr/lib64/libstdc++.so.6
。您可以采取多种修复措施。
应该显示设置 LD_LIBRARY_PATH 足以将二进制文件重定向到正确的库,并且
应该运行。您可以通过使用
-Wl,-rpath=/usr/local/lib64
重新链接该路径,将其“烘焙”到 m5.opt 二进制文件中。更永久的解决方案是以修复二进制文件的方式修复库:
更好的解决方案是使用
--prefix=/usr
重新配置新的GCC
,并且然后全部安装
。The problem is that you built your new
GCC
incorrectly: on Linux you should useThe default installation prefix is
/usr/local
, which is whymake install
putgcc
andg++
binaries into/usr/local/bin
, etc.What's happening to you now is that you compile and link using the new (symlinked)
GCC 4.2.4
, but at runtime your program binds to the old/usr/lib64/libstdc++.so.6
(version 6.0.8, instead of required 6.0.9). You can confirm that by runningldd build/ALPHA_SE/m5.opt
: you should see that it uses/usr/lib64/libstdc++.so.6
.There are several fixes you could do.
should show you that setting
LD_LIBRARY_PATH
is sufficient to redirect the binary to correct library, andshould just run. You could "bake" this path into m5.opt binary by relinking it with
-Wl,-rpath=/usr/local/lib64
.A more permanent solution is to fix the libraries the same way you fixed the binaries:
An even better solution is to reconfigure the new
GCC
with--prefix=/usr
, and thenmake all install
.我知道这是一个非常古老的问题,但是......
替换系统编译器(即
/usr
中的编译器)通常不是一个好主意,因为整个系统都是用它构建的并且依赖它。通常最好将新编译器安装到单独的位置,然后查看 libstdc++ 常见问题解答 如何确保会找到动态链接库吗?和手册中的查找动态或共享库,了解如何确保在运行时找到正确的 libstdc++.so。
I know this is a very old question, but ...
It's not usually a good idea to replace the system compiler (i.e. the one in
/usr
) because the entire system will have been built with it and depend on it.It's usually better to install the new compiler to a separate location and then see the libstdc++ FAQ How do I insure that the dynamically linked library will be found? and Finding Dynamic or Shared Libraries in the manual for how to ensure the correct libstdc++.so is found at runtime.
这里的其他答案应该没问题,但是如果您碰巧将 gcc 安装到 /usr/local/ ,那么“快速而简单”的解决方案就是将新的库添加到 LD_LIBRARY_PATH
您还可以检查以查看是否有使用我从另一个论坛得到的最后一条提示安装了正确版本的 GLIBC,
所以学分到期!
The other answers here should be fine, but the 'quick and easy' solution if you do happen to have gcc installed to /usr/local/ is to just add the new libs to the LD_LIBRARY_PATH
You can also check the to see if you have the right versions of GLIBC installed using
I got this last tip from another forum so credits due where credits due!