Can't link against Boost.Thread 1.46.1 with MinGW 4.5.2

老子叫甜甜 提交于 2019-12-02 05:12:06

问题


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?


回答1:


Try adding the compiler option '-DBOOST_THREAD_USE_LIB'



来源:https://stackoverflow.com/questions/5474475/cant-link-against-boost-thread-1-46-1-with-mingw-4-5-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!