升压线程错误:未定义参考 [英] Boost thread error: undefined reference

查看:397
本文介绍了升压线程错误:未定义参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <boost/thread/thread.hpp>
#include <iostream>

void hello()
{
  std::cout <<
    "Hello world, I'm a thread!"
    << std::endl;
}

int main(int argc, char* argv[])
{
  boost::thread thrd(&hello);
  thrd.join();
  return 0;
}

我跑试图编译这个程序,并得到了这些错误:

I ran tried to compile this program, and got these errors:

/usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to
   `boost::thread_resource_error::thread_resource_error()'
/usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to 
   `boost::thread_resource_error::~thread_resource_error()'
/usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to 
   `typeinfo for boost::thread_resource_error'
./src/thread.o: In function `condition_variable':
/usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: 
  undefined reference to `boost::thread_resource_error::thread_resource_error()'
/usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: 
  undefined reference to `boost::thread_resource_error::~thread_resource_error()'
/usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: \
  undefined reference to `typeinfo for boost::thread_resource_error'
./src/thread.o: In function `thread_data_base':
/usr/include/boost/thread/pthread/thread_data.hpp:54: 
  undefined reference to `vtable for boost::detail::thread_data_base'
./src/thread.o: In function `thread<void (*)()>':
/usr/include/boost/thread/detail/thread.hpp:188: 
  undefined reference to `boost::thread::start_thread()'
./src/thread.o: In function `~thread_data':
/usr/include/boost/thread/detail/thread.hpp:40: 
  undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/usr/include/boost/thread/detail/thread.hpp:40: undefined reference to 
  `boost::detail::thread_data_base::~thread_data_base()'

任何一个可以告诉我为什么我收到此错误?

Can any one tell me why i am getting this error?

推荐答案

与MT标签编译即 -lboost_thread-MT

这篇关于升压线程错误:未定义参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆