对Boost线程的未定义引用

Undefined reference to Boost Thread

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

我正在尝试编译和使用Boost 1.54库,但遇到了死胡同。

我编译并安装了文档中提到的库:

./bootstrap.sh
./b2 install

我甚至尝试使用进行完全重新安装

./bootstrap.sh
./b2 threading=multi install

我已经使用-lboost_thread-L*path链接以增强*/bin.v2/libs

我仍然得到以下链接器错误:

undefined reference to boost::thread::start_thread_noexcept()
undefined reference to boost::thread::join_noexcept()

我在Eclipse中的Ubuntu 12.04上使用gcc 4.6.3。

有人知道我该怎么解决吗?

在ubuntu存储库上的默认boost经历了相当多的痛苦之后,我安装了带有默认选项的boost 1.54.0(从官方网页),以下对我有效:

g++ test.cpp -o test -L/usr/local/lib/ -lboost_thread

附言:在Ubuntu 12.04上,gcc 4.63.

p.S2:我的test.cpp中包括:

#include "boost/thread/thread.hpp"
#include  "boost/bind.hpp"