无法使用boost 1.48构建共享库

时间:2012-01-22 03:06:38

标签: c++ boost

我正在尝试在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配置的共享库。

1 个答案:

答案 0 :(得分:0)

我有一个类似的问题试图在标准的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挤压服务器是如何破坏的。我一直在编译其他挤压系统,没有任何问题。