Hi,
I’m new to Boost, I’ve been trying to use the
Thread library that boost offers. I’m on a Kubuntu 7.1 box using G++ 4.1
Compiler with Boost 1.34. I’ve only been successful compiling my project
when including libboost_thread-gcc41-mt-d.so
library file. I would much rather use the .a file however, If I try to use the libboost_thread-gcc41-mt-d.a library file, i
get the following errors:
/home/andresh/DVRTranslators/Boost/lib/libboost_thread-gcc41-mt-d.a(thread.o):
In function `boost::thread::join()':
/home/andresh/DVRTranslators/Boost/boost_1_34_1/libs/thread/src/thread.cpp:226:
undefined reference to `pthread_join'
/home/andresh/DVRTranslators/Boost/lib/libboost_thread-gcc41-mt-d.a(thread.o):
In function `~thread':
/home/andresh/DVRTranslators/Boost/boost_1_34_1/libs/thread/src/thread.cpp:191:
undefined reference to `pthread_detach'
/home/andresh/DVRTranslators/Boost/boost_1_34_1/libs/thread/src/thread.cpp:191:
undefined reference to `pthread_detach'
/home/andresh/DVRTranslators/Boost/lib/libboost_thread-gcc41-mt-d.a(thread.o):
In function `thread':
/home/andresh/DVRTranslators/Boost/boost_1_34_1/libs/thread/src/thread.cpp:156:
undefined reference to `pthread_create'
/home/andresh/DVRTranslators/Boost/boost_1_34_1/libs/thread/src/thread.cpp:156:
undefined reference to `pthread_create'
/home/andresh/DVRTranslators/Boost/lib/libboost_thread-gcc41-mt-d.a(mutex.o):
In function `boost::try_mutex::do_trylock()':
/home/andresh/DVRTranslators/Boost/boost_1_34_1/libs/thread/src/mutex.cpp:260:
undefined reference to `pthread_mutex_trylock'
collect2: ld returned 1 exit status
make: *** [listener] Error 1
I’ve used the Regex and Filesystem .a library files
without a problem, but the Thread .a library file won’t work.
Here is my code:
#include
<boost/thread/thread.hpp>
#include <iostream>
void helloworld()
{
std::cout
<< "Hello World!" << std::endl;
}
int main()
{
std::cout
<< "STARTING ";
boost::thread thrd(&helloworld);
thrd.join();
helloworld();
return
0;
}
Here is my MakeFile:
all: listener
listener: TestBoost.cpp
g++
TestBoost.cpp -o listener -I
/home/andresh/DVRTranslators/Boost/include/boost-1_34_1/
/home/andresh/DVRTranslators/Boost/lib/libboost_thread-gcc41-mt-d.a
Any help is greatly appreciated. If
you need any more information please ask, I want to try and get this problem
resolved soon.
Thanks,
Andres