"xiaofeng liao"
I got undefefined reference errors while using thread libs, I reviewd some existing post on this subject, but still can't solve my problem.
Then I compile it use the following cmd, very similar to the previous one " c++ -I /usr/local/boost_1_37_0 thre.cpp -o thre /usr/local/boost_1_37_0/lib/libboost_thread-gcc41-mt-1_37.a" but I got the following errors: ------------------------------------------------------------------------------------- /usr/local/boost_1_37_0/lib/libboost_thread-gcc41-mt-1_37.a(thread.o): In function `boost::detail::set_current_thread_data(boost::detail::thread_data_base*)': thread.cpp:(.text+0x12a): undefined reference to `pthread_setspecific'
This is a clue: pthread_setspecific is part of the pthread library, not Boost.Thread. On linux, the thread library depends on the pthreads library, so you also need -lpthread on your command line. c++ -I /usr/local/boost_1_37_0 thre.cpp -o thre \ /usr/local/boost_1_37_0/lib/libboost_thread-gcc41-mt-1_37.a -lpthread You may also need a "-mthread" or "-mthreads" or "-pthread" compiler switch to enable gcc to generate multi-thread compatible code. Anthony -- Anthony Williams Author of C++ Concurrency in Action | http://www.manning.com/williams Custom Software Development | http://www.justsoftwaresolutions.co.uk Just Software Solutions Ltd, Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK