在我的项目中遇到错误后,我试图使用 C++ 在 Xcode (4.2) 上运行一个小型测试程序。
#include <boost/thread.hpp>
#include <boost/bind.hpp>
int main (int argc, const char * argv[])
{
boost::thread_group tg;
return 0;
}
但是整个程序构建失败,输出错误:
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();
编译没有问题,直到我尝试调用
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,没有任何问题。但是在尝试使用线程时遇到这些。
我需要:
- 在我的“其他链接器标志”上指定标志?
- 重新安装升压或某种?目前我正在使用 Boost 1.49.0,使用 homebrew 安装(即 sudo brew install boost)
还是我需要包括任何其他特定配置?