问题描述:

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()'

...

...

网友答案:

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

相关阅读:
Top