在使用Boost 1.53的链接阶段未定义的引用

undefined references during link phase using Boost 1.53

本文关键字:链接 未定义 引用 Boost      更新时间:2023-10-16

我在Red Hat Linux rel 5.5上使用g++ 4.1.2和Boost 1.53。在链接过程中有一个问题,我不清楚。我得到错误消息:

/usr/local/boost_1_53_0/stage/lib/libboost_thread.so: 
 undefined reference to     `std::bad_exception::what() const@GLIBCXX_3.4.9'
/usr/local/boost_1_53_0/stage/lib/libboost_thread.so: 
undefined reference to `std::bad_alloc::what() const@GLIBCXX_3.4.9'
collect2: ld returned 1 exit status

似乎有一个问题与我链接的libstdc++.so文件版本有关。如果我交替隐藏和显示这个文件,我可以让我的程序链接。但是,我希望能够像在介绍Boost库和并发线程之前那样一步完成。

请尝试通过yum安装

yum install boost你不会遇到这样的问题。

尝试包含rpmforge和epel yum库

http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning显示GLIBCXX_3.4.9libstdc++.so从GCC 4.2.0使用的符号版本,所以如果Boost库想要那个版本,那么它意味着它是用GCC 4.2.x编译的

这意味着你不能在GCC 4.1.2链接的程序中使用该库,你需要链接到GCC 4.2.0或更高版本

libstdc++.so是向后兼容的,但不是向前兼容的,所以你可以用一个版本编译程序并将其链接到一个新版本,但你不能用一个新版本编译程序并链接到一个旧版本。