Boost logo

Boost Users :

Subject: [Boost-users] simple thread program hardtocompile/link with 1.46.1
From: Eric Lin (kingdavid1_at_[hidden])
Date: 2011-05-22 02:23:19


Dear boost program(for c++,(or g++)):

  after I download 1.46.1 and try to baseon it to compile a simple
program from book C++cookbook, at page 447, 12.1 Creating a Thread

----------

// example 12-1. Creating a thread

#include <iostream>

#include <boost/thread/thread.hpp>

#include <boost/thread/xtime.hpp>

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_at_eric-laptop:~/cppcookbook$ ls

example12-1.cpp

eric_at_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_at_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_at_eric-laptop:~/cppcookbook$ cd ../boost1/boost_1_46_1/

eric_at_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
                                               


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net