AMDG On 05/21/2011 11:23 PM, Eric Lin wrote:
Dear boost program(for c++,(or g++)): after I download 1.46.1 and try to base on it to compile a simple program from book C++cookbook, at page 447, 12.1 Creating a Thread
You need to build the thread library. See http://www.boost.org/more/getting_started/unix-variants.html If you've already compiled the library, try -lboost_thread. If you didn't install the libraries to a system location, then you'll also need -L/path/to/compiled/libraries
----------
// example 12-1. Creating a thread #include <iostream> #include
#include struct MyThreadFunc { void operator()() { // Do something long-running... } } threadFun;
int main() { boost::thread myThread(threadFun); // Create a thread that starts // running threadFun boost::thread::yield(); // give up the main thread's timeslice // so the child thread can get some work // done.
// Go do some other work...
myThread.join(); // The current (i.e., main) thread will wait // for myThread to finish before it returns }
-----------------------------------------------------------
eric@eric-laptop:~/cppcookbook$ ls example12-1.cpp eric@eric-laptop:~/cppcookbook$ g++ -I/home/eric/boost1/boost_1_46_1/ example12-1.cpp -lboost_thread-mt /usr/bin/ld: cannot find -lboost_thread-mt collect2: ld returned 1 exit status eric@eric-laptop:~/cppcookbook$ g++ -I/home/eric/boost1/boost_1_46_1/ example12-1.cpp -lboost /usr/bin/ld: cannot find -lboost collect2: ld returned 1 exit status eric@eric-laptop:~/cppcookbook$ cd ../boost1/boost_1_46_1/ eric@eric-laptop:~/boost1/boost_1_46_1$
--------------------------
I am in Ubuntu linux 10.04, g++ 4.4.3
looking to see any suggestion and thanks a lot in advance, Eric Lin, Us citizen, in Los Angeles I am glad to meet anyone in Los Angeles on computer science meeting
In Christ, Steven Watanabe