G++ 无法使用 Boost for x86 编译代码



我有一个问题:我使用Boost(locks.hpp)编写了代码。我的服务器正在运行x64 Ubuntu(Linux)。当我使用 -m64 编译此代码时,它构建良好。但是当我尝试为-m32编译时,我收到以下错误:

g++ -fPIC -m32 -shared -Wl,-soname,test.so -ldl -o test.so test.cpp -lboost_thread
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libboost_thread.so when searching for -lboost_thread
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libboost_thread.a when searching for -lboost_thread
/usr/bin/ld: skipping incompatible //usr/lib/libboost_thread.so when searching for -lboost_thread
/usr/bin/ld: skipping incompatible //usr/lib/libboost_thread.a when searching for -lboost_thread
/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status

我做错了什么? 谢谢!

尝试安装 32 位提升包:

sudo apt-get install libboost-thread-dev:i386 

您需要 32 位版本的线程库。您的问题的答案已经在 stackoverflow.com。从源代码构建 boost 时使用地址模型选项。Boost 为在 Linux 上进行构建提供了很好的文档。

bjam address-model=32

最新更新