Boost logo

Boost-Build :

Subject: [Boost-build] undefined reference to pthread
From: Mathieu Champlon (m.champlon_at_[hidden])
Date: 2015-09-07 16:45:23


Hello,

My project uses Boost.Build, here is what my unit tests jamfile (partly)
looks like

rule run-test ( name )
{
   run $(name) /boost//unit_test_framework /boost//thread : : :
<define>BOOST_THREAD_USES_MOVE : $(name)_thread_safe ;
}

rule run-tests
{
   for name in [ glob test_*.cpp detail/test_*.cpp ] { run-test $(name) ; }
}

Before Boost 1.59 this was linking fine but with Boost 1.59 (and master)
it fails.
(I have continuous integration testing ranging several versions of boost)
Here is the error:

gcc.link
bin/test_sequence~cpp_thread_safe.test/gcc-4.6/debug/test_sequence~cpp_thread_safe

bin/test_sequence~cpp_thread_safe.test/gcc-4.6/debug/test_sequence.o: In
function `recursive_mutex':

/home/travis/boost/boost/thread/pthread/recursive_mutex.hpp:67:
undefined reference to `pthread_mutexattr_init'

/home/travis/boost/boost/thread/pthread/recursive_mutex.hpp:72:
undefined reference to `pthread_mutexattr_settype'

/home/travis/boost/boost/thread/pthread/recursive_mutex.hpp:75:
undefined reference to `pthread_mutexattr_destroy'

/home/travis/boost/boost/thread/pthread/recursive_mutex.hpp:82:
undefined reference to `pthread_mutexattr_destroy'

/home/travis/boost/boost/thread/pthread/recursive_mutex.hpp:85:
undefined reference to `pthread_mutexattr_destroy'

collect2: ld returned 1 exit status

"g++" -Wl,-R
-Wl,"/home/travis/boost/bin.v2/libs/chrono/build/gcc-4.6/debug" -Wl,-R
-Wl,"/home/travis/boost/bin.v2/libs/chrono/build/gcc-4.6/debug/threading-multi"
-Wl,-R -Wl,"/home/travis/boost/bin.v2/libs/system/build/gcc-4.6/debug"
-Wl,-R
-Wl,"/home/travis/boost/bin.v2/libs/system/build/gcc-4.6/debug/threading-multi"
-Wl,-R -Wl,"/home/travis/boost/bin.v2/libs/test/build/gcc-4.6/debug"
-Wl,-R
-Wl,"/home/travis/boost/bin.v2/libs/thread/build/gcc-4.6/debug/threading-multi"
-Wl,-R -Wl,"/home/travis/boost/bin.v2/libs/timer/build/gcc-4.6/debug"
-Wl,-rpath-link
-Wl,"/home/travis/boost/bin.v2/libs/chrono/build/gcc-4.6/debug"
-Wl,-rpath-link
-Wl,"/home/travis/boost/bin.v2/libs/chrono/build/gcc-4.6/debug/threading-multi"
-Wl,-rpath-link
-Wl,"/home/travis/boost/bin.v2/libs/system/build/gcc-4.6/debug"
-Wl,-rpath-link
-Wl,"/home/travis/boost/bin.v2/libs/system/build/gcc-4.6/debug/threading-multi"
-Wl,-rpath-link
-Wl,"/home/travis/boost/bin.v2/libs/test/build/gcc-4.6/debug"
-Wl,-rpath-link
-Wl,"/home/travis/boost/bin.v2/libs/thread/build/gcc-4.6/debug/threading-multi"
-Wl,-rpath-link
-Wl,"/home/travis/boost/bin.v2/libs/timer/build/gcc-4.6/debug" -o
"bin/test_sequence~cpp_thread_safe.test/gcc-4.6/debug/test_sequence~cpp_thread_safe"
-Wl,--start-group
"bin/test_sequence~cpp_thread_safe.test/gcc-4.6/debug/test_sequence.o"
"bin/test_sequence~cpp_thread_safe.test/gcc-4.6/debug/undefined.o"
"/home/travis/boost/bin.v2/libs/test/build/gcc-4.6/debug/libboost_unit_test_framework.so.1.59.0"
"/home/travis/boost/bin.v2/libs/thread/build/gcc-4.6/debug/threading-multi/libboost_thread.so.1.59.0"
"/home/travis/boost/bin.v2/libs/system/build/gcc-4.6/debug/libboost_system.so.1.59.0"
"/home/travis/boost/bin.v2/libs/chrono/build/gcc-4.6/debug/threading-multi/libboost_chrono.so.1.59.0"
"/home/travis/boost/bin.v2/libs/system/build/gcc-4.6/debug/threading-multi/libboost_system.so.1.59.0"
-Wl,-Bstatic -Wl,-Bdynamic -Wl,--end-group -g --coverage

...failed gcc.link
bin/test_sequence~cpp_thread_safe.test/gcc-4.6/debug/test_sequence~cpp_thread_safe...

It looks like -pthread is missing from the command line, but isn't
Boost.Build supposed to take care of this ?
The system is a linux, probably ubuntu but not sure, it's run by
travis-ci, see https://travis-ci.org/mat007/turtle

Any clue what is going wrong and how I can fix it ?

Many thanks !
MAT.


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk