Hi, there,
The most updated version of boost on my Ubuntu is 1_40_0. So I choose to compile and install 1_43_0 from source code. During the building process of step 4 (mentioned bellow), I was prompted that boost::thread, boost::mpi, etc. libraries need to be compiled and installed separetly. I ignored them and finished the process.
Now I can run the following program sucessfully with
//
robert@ubuntu:~/boost$ g++ -I /home/robert/src/boost_1_43_0 example.cpp -o example
// echo 1 2 3 | ./example
for example.cpp
===================
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
===================
but failed to compile thread.cpp program with
for the following thread.cpp
===================
#include <boost/thread/thread.hpp>
#include <iostream>
void hello()
{
std::cout << "Hello world, I'm a thread!" << std::endl;
}
int main(int argc, char* argv[])
{
boost::thread thrd(&hello);
thrd.join();
return 0;
}
===================
The first few complaints I got are:
----------------------------------------------
/tmp/ccwgSZ3d.o: In function `main':
thread.cpp:(.text+0x6e): undefined reference to `boost::thread::join()'
thread.cpp:(.text+0x7f): undefined reference to `boost::thread::~thread()'
thread.cpp:(.text+0xa0): undefined reference to `boost::thread::~thread()'
/tmp/ccwgSZ3d.o: In function `boost::detail::thread_data_base::thread_data_base()':
How can I compile boost::thread separately for it to work? Thanks a lot.
By the way, these are steps I did to compile and install boost_1_43_0 in case that you may want to review it (or I did something wrong):
[NOTE: The downloaded boost_1_43_0 source code located at my home directory: ~/src/ ]
(0)
cd ~/src
(2)
tar zxvf boost_1_43_0.tar.gz
(3)
cd boost_1_43_0
(4)
(5)
./bjam install