I’ve been working on this for a while and cannot understand the situation - in part because I don’t quite understand what is happening (that’s why I came here).
I make a kind of greeting to the world:
#include <boost/thread/thread.hpp> #include <cstdio> void helloworld() { std::printf("HELLO FROM A BOOST THREAD!"); } int main(int argc, char **argv) { boost::thread t(&helloworld); t.join(); }
This is on Windows. I saved the Boost directory in C: \ Boost. I launched bootstrap and bjam, and now I have a stage / lib folder containing all the .lib files. Lib files related to boost / thread library:
libboost_thread-vc100-mt.lib libboost_thread-vc100-mt-1_46_1.lib libboost_thread-vc100-mt-gd.lib libboost_thread-vc100-mt-gd-1_46_1.lib
Now I will compile:
g++ -c main.cpp -I/Boost
this line is working fine, I get main.o. Then:
g++ -o test.exe main.o -L/Boost/stage/lib -llibboost_thread-vc100-mt
And what is where the problem is. First of all, if I hadn't typed the -l argument the way I did, MinGW couldn't even find the file. Meaning if I tried:
-lboost_thread-vc100-mt
instead of typing it above (and as I thought it should be done), ld will exit without such a file. In any case, now this is the result that I get from this line:
main.o:main.cpp:(.text+0x47): undefined reference to `_imp___ZN5boost6thread4joinEv' main.o:main.cpp:(.text+0x55): undefined reference to `_imp___ZN5boost6threadD1Ev' main.o:main.cpp:(.text+0x70): undefined reference to `_imp___ZN5boost6threadD1Ev' main.o:main.cpp:(.text$_ZN5boost6threadC1IPFvvEEET_NS_10disable_ifINS_14is_convertibleIRS4_NS_6detail13thread_move_tIS4_EEEEPNS0_5dummyEE4typeE[boost::thread::thread<void (*)()>(void (*)(), boost::disable_if<boost::is_convertible<void (*&)(), boost::detail::thread_move_t<void (*)()> >, boost::thread::dummy*>::type)]+0x23): undefined reference to `_imp___ZN5boost6thread12start_threadEv' collect2: ld returned 1 exit status
Now, somewhere out there, I can say that these are apparently the functions that I should get from boost / thread, and apparently it finds the lib file, so why doesn't it link correctly?
Thanks so much for any help!
EDIT:
I updated forcing using the bjam stage option
bjam toolset=gcc stage
Now, after the build is complete, I still have the stage / lib folder with the .a files, as you would expect. These are the libraries related to boost / thread:
libboost_thread-mgw45-mt-1_46_1.a libboost_thread-mgw45-mt-d-1_46_1.a
However, connecting as follows:
g++ -o test.exe main.o -L/Boost/stage/lib -lboost_thread-mgw45-mt-1_46_1
displays the same errors. Also tried:
g++ -o test.exe main.o -L/Boost/stage/lib -lboost_thread-mgw45-mt-1_46_1 -static
I'm still at a loss.