eclipse 对 Boost Thread 的未定义引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17455928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 20:50:23  来源:igfitidea点击:

Undefined reference to Boost Thread

c++eclipsemultithreadingubuntuboost

提问by Zippo

I am trying to compile and use the Boost 1.54 libraries and have run into a deadend.

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

I compiled and installed the libraries like mentioned in the documentation:

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

./bootstrap.sh
./b2 install

I even tried a complete reinstall using:

我什至尝试使用以下方法完全重新安装:

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

I have linked using -lboost_threadand -L*pathto boost*/bin.v2/libs

我已经链接 using-lboost_thread-L*pathto boost*/bin.v2/libs

I am still getting the following linker errors:

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

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

I am using gcc 4.6.3 on Ubuntu 12.04 in Eclipse.

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

Does anyone know how I can fix this?

有谁知道我该如何解决这个问题?

回答by Ana

After quite a bit of pain with the default boost on ubuntu repositories, I installed boost 1.54.0 (from the official webpage) with the default options, and the following worked for me:

在 ubuntu 存储库上使用默认 boost 相当痛苦之后,我使用默认选项安装了 boost 1.54.0(来自官方网页),以下对我有用:

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

P.S: On Ubuntu 12.04, gcc 4.63.

PS:在 Ubuntu 12.04 上,gcc 4.63

P.S2: Included in my test.cppare:

P.S2:我的test.cpp包括:

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