Unable to associate with Boost.Thread 1.46.1 with MinGW 4.5.2

I built boost using:

bjam --toolset=gcc --with-thread stage 

Whenever I try to use Boost.Thread, I get undefined links, although I link to it. This does not happen with other Boost libraries such as 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 

Program Example:

 #include <boost/thread.hpp> #include <iostream> int main() { std::cout << boost::thread::hardware_concurrency() << std::endl; } 

What am I doing wrong?

+2
source share
1 answer

Try adding the compiler option '-DBOOST_THREAD_USE_LIB'

+9
source

All Articles