未能使用boost 1.48构建共享库

failed to build shared libraries with boost 1.48

本文关键字:构建 共享 boost      更新时间:2023-10-16

我正试图在amd64计算机上构建boost 1.48,但由于重新定位错误,共享库没有构建。我认为这是由于-fPIC,但这就是无法解决的原因。

更具体地说,这是我得到的,通过主干

$ ./b2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a(codecvt.o): relocation R_X86_64_32S against `vtable for std::codecvt<wchar_t, char, __mbstate_t>' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

我也试过这些

./bjam -d2
./bjam address-model=64 cxxflags=-fPIC

如本文所述

http://boost.2283326.n4.nabble.com/fPIC-option-for-boost-td3176976.html

然而,这并没有起到任何作用。我无法构建使用boostrap.sh配置的共享库。

我在尝试在标准debian挤压安装上构建mosh-1.2.2时遇到了类似的问题。以下对我有效:

# cd /usr/lib/gcc/x86_64-linux-gnu/4.4.5
# rm libstdc++.so
# ln -s ../../../x86_64-linux-gnu/libstdc++.so.6 libstdc++.so

为了更详细地解释,现有的符号链接指向一个不存在的文件:

# cd /usr/lib/gcc/x86_64-linux-gnu/4.4.5
# ls -l libstdc++.so
..
lrwxrwxrwx 1 root root      23 May  3  2011 libstdc++.so -> ../../../libstdc++.so.6
..

我找到了正确的文件位置

# dpkg -S 'libstdc'
..
libstdc++6: /usr/lib/x86_64-linux-gnu/libstdc++.so.6
..

然后按照第一个代码段中的描述修复了符号链接。

我在编译过程中得到的错误是:

make[3]: *** [mosh-client] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_typeid::~bad_typeid()' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a: could not read symbols: Bad value

不知道这个特定的debian挤压服务器是怎么坏的。我一直在其他挤压系统上进行编译,没有遇到任何问题。