c++ - boost::thread undefined reference -


i installed boost libraries , trying use multi - threading. copied example boost library example. getting error:

undefined reference boost::thread::join()

here code,

#include <boost/thread.hpp> #include <boost/thread/xtime.hpp> #include <iostream>  struct thread_alarm {     thread_alarm(int secs) : m_secs(secs) { }     void operator()()     {         boost::xtime xt;         boost::xtime_get(&xt, boost::time_utc);         xt.sec += m_secs;          boost::thread::sleep(xt);          std::cout << "alarm sounded..." << std::endl;     }      int m_secs; };  int main(int argc, char* argv[]) {     int secs = 5;     std::cout << "setting alarm 5 seconds..." << std::endl;     thread_alarm alarm(secs);     boost::thread thrd(alarm);     thrd.join(); } 

which compiler?

try if gcc

$ g++ -o ./app.out ./source.cpp -lboost_thread 

if running on windows, perhaps have make sure pthread have installed, , have tell compiler , how link them together, application , 3rd party lib such boost_thread.

hope useful you


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -