c++ - How to resolve compilation errors for boost multithreading simple program -
I have a problem compiling a boost integrated source code in my PC I am working on the environment below for compilation Event: Error output: Errors as the console console compiler can not find methods declared in the library. I tried several sample applications but the result was the same. Please help me figure out the problem or give me a way to check the installation status of promoting. For example, you should call the Boost_thread Library
#include & lt; boost / thread.hpp & gt; # Include & lt; Iostream & gt; using namespace std; Zero threadfunction () {int counter = 0; (;;) {std :: cout & lt; & Lt; "Walking Thread" & lt; & Lt; ++ Counter & lt; & Lt; "Press Enter to stop" & lt; & Lt; Std :: endl; Try {// sleep and check in between. // To check for interrupts without sleep, // use boost :: this_thread :: interruption_point () // whatever promotes: Thread_Inverweld boost :: this_thread :: sleep (boost :: posix_time :: milliseconds (500)); } Hold (boost: Thread Interactive & amp;) {std :: cout & lt; & Lt; "Thread is paused" & lt; & Lt; Std :: endl; Return; }}} Int main () {// Start Thread Boost :: Thread T (and ThreadFunction); // Wait for four characters to enter; std :: cin.get (ch); // t.interrupt ask thread to stop (); // join - wait when the thread actually exits t.join (); Std :: cout & lt; & Lt; "Main: Thread Done" & lt; & Lt; Std :: endl; Return 0; }
Build: Debug in testPro (compiler: GNU GCC compiler) === | Obj / debug / main.o || Function in `main ': | & Lt; Path for code & gt; /main.cpp | 40 | To promote the mentioned reference: thread :: thread :: interrupt () | & Lt; Path for code & gt; /main.cpp | 43 | Undefined context: `promotional: thread :: add () 'for | & Lt; Path for code & gt; /main.cpp | 47 | Undefined reference to `boost :: thread :: ~ thread () '| & Lt; Path for code & gt; /main.cpp | 47 | Undefined reference to `boost :: thread :: ~ thread () '| Obj / debug / main.o || In function `thread_data_base ': | /usr/include/boost/thread/pthread/thread_data.hpp:65 `vtable :: extension :: thread_data_base 'for reference for New Zealand reference. Obj / debug / main.o || In the function `zero bust :: this_thread :: sleep & lt; Boost :: date_time :: subsecond_duration & lt; Boost :: posix_time :: time_duration, 1000l & gt; & Gt; (Promotion: date_time :: subsecond_digit & quot; promotion :: posix_time :: time_duration, 1000l & gt; CONST & amp;) ': | /usr/include/boost/thread/pthread/thread_data.hpp|122 `Promotion :: this_thread :: sleep (boost :: posix_time :: ptime const & amp;) for nudferring references' | obj / debug / main.o || Function `Thread & lt; void (*) ()> ': | | /usr/include/boost/thread/detail/thread.hpp|191 Nudfacing reference `promotion: thread :: start_thread () 'in context. Obj / debug / main.o || In function `~ thread_data ': | /usr/include/boost/thread/detail/thread.hpp|40 In the context of New Zealand `Promotion :: Extension :: thread_data_base :: ~ thread_data_base () '. ] + 0x10) || Typeinfo :: extension :: thread_data_base 'to promote disorganized context. || === Build fail: 9 error (), 0 warnings (0 minutes (s), 1 second (second)) === |
-lboost_thread Need to compile your code with
GCC test.c -o test -lboost_thread
Comments
Post a Comment