无法将 Boost.Thread 1.46.1 与 MinGW 4.5.2 链接
我已经使用以下方法构建了 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;
}
我做错了什么?
I've built boost using:
bjam --toolset=gcc --with-thread stage
Whenever I'm trying to actually use Boost.Thread I'm getting undefined references although I link against it. It doesn't happen with other Boost libraries like Regex or 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
Example program:
#include <boost/thread.hpp>
#include <iostream>
int main()
{
std::cout << boost::thread::hardware_concurrency() << std::endl;
}
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试添加编译器选项“-DBOOST_THREAD_USE_LIB”
Try adding the compiler option '-DBOOST_THREAD_USE_LIB'