Need help with boost

So because MinGW doesn't yet support C++11 threads, I was just going to use boost's threads, however, I can't get even very simple example code to compile that makes use of only boost threads...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <boost/chrono.hpp>
#include <boost/date_time.hpp>
#include <boost/thread.hpp>

void blah(){
    std::cout<<"blah..."<<std::endl;
    return;
}

int main()
{
    boost::thread blahT(blah);

    return 0;
}


and I set Codeblocks to include libboost_system-mgw47-mt-s-1_52.a, libboost_chrono-mgw47-mt-s-1_52.a, and, obviously, libboost_thread-mgw47-mt-s-1_52.a, [I had to build boost from source with boostbuild]

As a side note, it seams I am never able to compile any libraries from source without having some issues with the generated binaries, I don't know if its how I build them or what, but I tend to get errors like this...

1
2
3
4
5
6
7
8
9
C:\Users\[redacted]\Desktop\test cpp11\test.o||In function `ZN5boost6detail16thread_data_baseC2Ev':|
c:\mingw\bin\..\lib\gcc\mingw32\4.7.2\..\..\..\..\include\boost\thread\win32\thread_data.hpp|108|undefined reference to `_imp___ZTVN5boost6detail16thread_data_baseE'|
C:\Users\[redacted]\Desktop\test cpp11\test.o||In function `ZN5boost6threadD1Ev':|
c:\mingw\bin\..\lib\gcc\mingw32\4.7.2\..\..\..\..\include\boost\thread\detail\thread.hpp|179|undefined reference to `_imp___ZN5boost6thread6detachEv'|
C:\Users\[redacted]\Desktop\test cpp11\test.o||In function `ZN5boost6threadC1IRFvvEEEOT_NS_10disable_ifINS_7is_sameINS_5decayIS4_E4typeES0_EEPNS0_5dummyEE4typeE':|
c:\mingw\bin\..\lib\gcc\mingw32\4.7.2\..\..\..\..\include\boost\thread\detail\thread.hpp|191|undefined reference to `_imp___ZN5boost6thread12start_threadEv'|
C:\Users\[redacted]\Desktop\test cpp11\test.o||In function `ZN5boost6detail11thread_dataIPFvvEED1Ev':|
c:\mingw\bin\..\lib\gcc\mingw32\4.7.2\..\..\..\..\include\boost\thread\detail\thread.hpp|52|undefined reference to `_imp___ZN5boost6detail16thread_data_baseD2Ev'|
||=== Build finished: 4 errors, 0 warnings (0 minutes, 6 seconds) ===|


which this is the error I'm currently getting when trying to compile the above code. Anyone know what my issue may be?

EDIT: After doing a VERY specific search on google for the first error I got from the compiler, I found out that I have to use the macro BOOST_THREAD_USE_LIB to enable use of the libraries with boost (seams kind of illogical though for thread and system [possibly chrono?] as they both must have their respective libraries built and linked to to make use of their functions and stuff...)
Last edited on
Topic archived. No new replies allowed.