我使用以下方法构建了 boost:
bjam --toolset=gcc --with-thread stage
每当我尝试实际使用 Boost.Thread 时,尽管我链接了它,但我都会收到未定义的引用。其他 Boost 库(例如 Regex 或 System)不会发生这种情况。
>g++ main.cpp -I. -L. -lboost_thread-mgw45-mt-1_46_1
C:\Users\jhasse\AppData\Local\Temp\ccjYfDox.o:main.cpp:(.text+0xf): undefined reference to `_imp___ZN5boost6thread20hardware_concurrencyEv'
collect2: ld returned 1 exit status
示例程序:
#include <boost/thread.hpp>
#include <iostream>
int main()
{
std::cout << boost::thread::hardware_concurrency() << std::endl;
}
我究竟做错了什么?
尝试添加编译器选项“-DBOOST_THREAD_USE_LIB”
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)