我遇到了问题:我使用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
我做错了什么?谢谢!
答案 0 :(得分:3)
尝试安装32位增强包:
sudo apt-get install libboost-thread-dev:i386
答案 1 :(得分:2)
您需要32位版本的线程库。你问题的answer已经在stackoverflow.com上了。从源构建boost时,请使用 address-model 选项。 Boost为在Linux上构建提供了很好的documentation。
bjam address-model=32