views:

72

answers:

1

I installed the boost package from cygwin and have a directory /usr/include/boost that includes a bunch of *.hpp files, including thread.hpp, which I need to include in the c++ file, via

#include <boost/thread.hpp>

Also, several *.a files seem to be related to boost::thread.

$ ls /usr/lib/libboost_thread* -1
/usr/lib/libboost_thread-gcc-mt-1_33_1.a
/usr/lib/libboost_thread-gcc-mt.a
/usr/lib/libboost_thread-mt.a
/usr/lib/libboost_thread-mt.dll.a

What should my g++ compilation command look like? I understand I should be using some combination of -L -I, and -l, but I'm not sure what to supply for each argument, and nothing is working for me so far.

I have tried the following:

$ g++ test.cpp -lboost_thread-gcc-mt
/cygdrive/c/Users/jonderry/AppData/Local/Temp/ccaNCMaA.o:test.cpp:(.text$_ZN5boost6detail11thread_dataIPFvvEED
0Ev[boost::detail::thread_data<void (*)()>::~thread_data()]+0x16): undefined reference to `boost::detail::thre
ad_data_base::~thread_data_base()'
...
...
+1  A: 

EDIT (removed -gcc part): g++ sample.cpp -lboost_thread-mt. You may need to add -lpthread or -pthread as well. If still no luck, please post the errors you get. HTH

usta
Question updated with the error output. I tried -lpthread and -pthread as well, but the result was the same (-pthread was an unrecognized option)
jonderry
@jonderry: Strange. Does `-lboost_thread-mt` (without -gcc) work better?
usta
Yes. It works. Thanks!
jonderry
@jonderry: Glad it helped. Anyway here is the changes history for Boost.Thread: http://www.boost.org/doc/libs/1_44_0/doc/html/thread/changes.html
usta