CentOS:从devtoolset使用GCC 4.7会导致错误地链接libstdc ++(未定义符号) [英] CentOS: Using GCC 4.7 from devtoolset results in linking libstdc++ incorrectly (undefined symbols)

查看:497
本文介绍了CentOS:从devtoolset使用GCC 4.7会导致错误地链接libstdc ++(未定义符号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为CentOS 6.3使用devtoolset-1.0,以便临时升级GCC版本。尽管我现在可以编译我的C ++应用程序,但最终的二进制文件缺少一些符号:

I am using the devtoolset-1.0 for CentOS 6.3 in order to upgrade temporarily the GCC version. Although I am now able to compile my C++ application, the final binary is missing some symbols:

$ ldd -d -r myapp
$     [..]
$     libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003216e00000)
$     [..]
$ undefined symbol: _ZNSt8__detail15_List_node_base11_M_transferEPS0_S1_    (./myapp)
$ undefined symbol: _ZNSt8__detail15_List_node_base7_M_hookEPS0_      (./myapp)
$ undefined symbol: _ZNSt8__detail15_List_node_base9_M_unhookEv (./myapp)

我发现,这些是一些新功能,在旧版本的libstdc ++中找不到,但是在较新的libstdc ++中。在我的系统上,同时安装了libstdc ++(默认版本4.4.7)和devtoolset-1.0-libstdc ++-devel(4.7通过devtoolset)。有趣的是,来自devtoolset的libstdc ++再次链接到旧版本:

I figured out, that these are some new functions, which aren't found in the 'old' libstdc++, but in a newer libstdc++. On my system, both libstdc++ (default version 4.4.7) and devtoolset-1.0-libstdc++-devel (4.7 via devtoolset) are installed. Interestingly, the libstdc++ from devtoolset links agains to the old one:

$ cat /opt/centos/devtoolset-1.0/root/usr/lib/gcc/x86_64-redhat-linux/4.7.0/libstdc++.so
$ /* GNU ld script
$    Use the shared library, but some functions are only in
$    the static library, so try that secondarily.  */
$ OUTPUT_FORMAT(elf64-x86-64)
$ INPUT ( /usr/lib64/libstdc++.so.6 -lstdc++_nonshared )

我真正想要的是替换libstdc ++绑定,但是我不知道该如何实现。我已经尝试设置LD_LIBRARY_PATH并指向devtoolset目录,但是libstdc ++仍然设置为旧位置。符号链接也没有成功,因为它是ld脚本而不是实际的共享库。

What I actually want is to replace the libstdc++ binding, but I don't know how to achieve that. I already tried to set LD_LIBRARY_PATH and pointing to the devtoolset directory, but the libstdc++ was still set to the old location. Also a symbolic link did not result in a success, because it is a ld script and not actual shared library.

推荐答案


最后的二进制文件缺少一些符号

the final binary is missing some symbols

这似乎是 devtoolset-1中的错误-gcc ,我认为已在最新版本的devtoolset中修复。

That looks like a bug in devtoolset-1-gcc, which I assume has been fixed in more recent versions of devtoolset.


有趣的是,来自的libstdc ++ devtoolset再次链接到旧的工具:

Interestingly, the libstdc++ from devtoolset links agains to the old one:

是的,这就是devtoolset gcc应该工作的方式(请参见此答案以获取更多详细信息)。

Yes, that's how the devtoolset gcc is supposed to work (see this answer for more details).


我实际上是什么想要替换libstdc ++绑定,但是我不知道该怎么实现。

What I actually want is to replace the libstdc++ binding, but I don't know how to achieve that.

GCC的devtoolset,因为它甚至没有新的 libstdc ++。so 库。如您所见,该文件实际上是一个链接描述文件,它将您的二进制文件链接到 libstdc ++ _ nonshared.a / usr / lib64 / libstdc ++。so

You can't do that with the devtoolset of GCC, because it doesn't even have a new libstdc++.so library. As you found, that file is actually a linker script, which links your binary to libstdc++_nonshared.a /usr/lib64/libstdc++.so

由于没有新的 libstdc ++。so ,因此您无法链接到它。

Since there is no new libstdc++.so you can't link to it.

这篇关于CentOS:从devtoolset使用GCC 4.7会导致错误地链接libstdc ++(未定义符号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆