gpt4 book ai didi

c++ - 使用 Eclipse 编译 boost::thread

转载 作者:搜寻专家 更新时间:2023-10-31 00:23:29 27 4
gpt4 key购买 nike

我正在使用 Ubuntu + Eclipse 并安装了 boost(不确定是否正确)。我使用 apt-get install libboost* 安装了 Boost

我测试了一些简单的代码,看起来 boost 工作正常。

但是,当我尝试学习线程部分时,下面的代码不起作用。

#include <boost/thread/thread.hpp> 
#include <iostream>
using namespace std;

void hello()
{
cout<<"hello!"<<endl;
}

int main()
{
boost::thread thrd(&hello);
cout<<"Just a test!"<<endl;
}

错误信息如下,有4个错误。

Severity and Description Path Resource Location Creation Time Id
/usr/local/include/boost/thread/detail/thread.hpp undefined reference to `boost::detail::thread_data_base::~thread_data_base()' FirstCppProject line 40 1260656497961 200


Severity and Description Path Resource Location Creation Time Id
/usr/local/include/boost/thread/detail/thread.hpp undefined reference to `boost::thread::start_thread()' FirstCppProject line 191 1260656497967 202


Severity and Description Path Resource Location Creation Time Id
/usr/local/include/boost/thread/pthread/thread_data.hpp undefined reference to `vtable for boost::detail::thread_data_base' FirstCppProject line 65 1260656497965 201


Severity and Description Path Resource Location Creation Time Id
undefined reference to `boost::thread::~thread()' FirstCppProject test.cpp line 15 1260656497959 199

如果我的问题太幼稚,请原谅我。请提供您认为可能对我有帮助的任何信息。

最佳答案

你必须链接线程库 libboost_thread_...

关于c++ - 使用 Eclipse 编译 boost::thread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1894912/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com