Xcode上的Boost线程组 [英] Boost's thread group on Xcode

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

问题描述

遇到项目错误后,我试图使用C ++在Xcode(4.2)上运行一个小型测试程序.

I was trying to run a small test program on Xcode (4.2) using C++ after encountering error in my project.

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

int main (int argc, const char * argv[])
{
    boost::thread_group tg;
    return 0;
}

但是整个程序无法构建,并输出错误:

But the whole program fails to build, outputting error:

Undefined symbols for architecture x86_64:
  "boost::thread::~thread()", referenced from:
      boost::thread_group::~thread_group()in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

然后我尝试使用

thread_group * tg = new thread_group();

可以编译,直到我尝试调用为止

which compiles without issue, up until I tried to invoke

tg->join_all();

编译器输出以下错误:

Undefined symbols for architecture x86_64:
  "boost::detail::get_current_thread_data()", referenced from:
      boost::detail::interruption_checker::interruption_checker(_opaque_pthread_mutex_t*, _opaque_pthread_cond_t*)in main.o
  "boost::this_thread::interruption_point()", referenced from:
      boost::condition_variable::wait(boost::unique_lock<boost::mutex>&) in main.o
  "boost::this_thread::disable_interruption::disable_interruption()", referenced from:
      boost::shared_mutex::lock_shared()      in main.o
  "boost::this_thread::disable_interruption::~disable_interruption()", referenced from:
      boost::shared_mutex::lock_shared()      in main.o
  "boost::thread::join()", referenced from:
      boost::thread_group::join_all()     in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

有人知道如何解决这些问题吗?我一直在使用其他功能,例如BOOST_FOREACH,没有任何问题.但是在尝试使用线程时会遇到这些问题.

Does anyone know how to resolve these issues ? I've been using other functions such as BOOST_FOREACH without any issues. But encounter these while trying to use threads.

我需要:

  • 在我的其他链接器标志"上指定标志?
  • 重新安装boost或某种形式?目前,我使用的是Boost 1.49.0,是通过自制程序安装的(即sudo brew install boost)

或者我需要包含其他任何特定的配置吗?

Or are there any other specific configurations that I need to to include ?

推荐答案

boost线程库具有您需要链接的实际库对象(-lboost_thread或有时是-lboost_thread-mt).

The boost thread library has an actual library object you need to link against (-lboost_thread or sometimes -lboost_thread-mt).

这篇关于Xcode上的Boost线程组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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