[boost::thread] program throws thread_resource_error on sun/solaris

I have written a prgram using boost::thread that works fine on a 32 and on a 64 bit linux machine. On a sun/solaris machine the program fails with the following message:
terminate called after throwing an instance of 'boost::thread_resource_error'
what(): boost::thread_resource_error Abort
The sun/solaris machine:
uname -a SunOS paris 5.9 Generic_118558-24 sun4u sparc SUNW,Sun-Fire-15000
I untared a fresh boost-package, build and tested it using:
SRCDIR="/TL/usr/lkunert/src" BOOSTDIR="${SRCDIR}/boost/boost_1_33_1"
cd ${BOOSTDIR}
bjam \ "-sTOOLS=gcc" \ "-sGCC_ROOT_DIRECTORY=${SRCDIR}/sun64/gcc-3.4" \ "-sGXX=g++-3.4" \ "-sGCC=gcc-3.4" \ \ "-sBUILD=<cxxflags>-m64 <linkflags>-m64 debug release" \ \ "--without-python" \ "--with-unit_test" \ "--with-thread"
and
bjam \ ... \ test
The build returned no errors:
... ar: creating bin/boost/libs/thread/build/libboost_thread.a/gcc/release/threading-multi/libboost_thread-gcc-mt-1_33_1.a ...updated 71 targets...
The test worked well too:
Building Boost.Regex with the optional Unicode/ICU support disabled. Please refer to the Boost.Regex documentation for more information (and if you don't know what ICU is then you probably don't need it). ...found 2 targets...
In my project I do not use bjam, but autoconf/automake. In order to test boost::thread by hand, I compiled some of the files in boost/libs/thread/test by hand...
${SRCDIR}/sun64/gcc-3.4/bin/g++-3.4 \ -I. \ -I${SRCDIR}/sun64/include \ -I${SRCDIR}/sun64/include/boost-1.33.1 \ -O3 -DNDEBUG -m64 -Wall \ -L${SRCDIR}/sun64/lib/boost-1.33.1-g++-3.4 -lboost_thread-gcc-mt -lboost_unit_test_framework-gcc \ -R${SRCDIR}/sun64/lib/boost-1.33.1-g++-3.4 \ -o test_barrier \ test_barrier.cpp
I get the following error message:
Running 1 test case... unknown location(0): fatal error in "test_barrier": std::exception: boost::thread_resource_error
*** errors detected in test suite "Boost.Threads: barrier test suite";
see standard output for details This is the same error I get from my own code. It seems, that the bjam-build systems does something right, that I do not know about. (Like linking to an addidtional library - but why do I not get a link-error.) I figured out, that boost::thread uses pthreads...
BOOST_HAS_THREADS BOOST_HAS_PTHREADS
are defined Thanks for your help, Lars Kunert

Lars Kunert <lkunert@mpi-sb.mpg.de> writes:
I have written a prgram using boost::thread that works fine on a 32 and on a 64 bit linux machine. On a sun/solaris machine the program fails with the following message:
terminate called after throwing an instance of 'boost::thread_resource_error'
Which means that it couldn't create an instance of a thread resource: a mutex, a thread, a condvar, etc.
In my project I do not use bjam, but autoconf/automake. In order to test boost::thread by hand, I compiled some of the files in boost/libs/thread/test by hand...
${SRCDIR}/sun64/gcc-3.4/bin/g++-3.4 \ -I. \ -I${SRCDIR}/sun64/include \ -I${SRCDIR}/sun64/include/boost-1.33.1 \ -O3 -DNDEBUG -m64 -Wall \ -L${SRCDIR}/sun64/lib/boost-1.33.1-g++-3.4 -lboost_thread-gcc-mt -lboost_unit_test_framework-gcc \ -R${SRCDIR}/sun64/lib/boost-1.33.1-g++-3.4 \ -o test_barrier \ test_barrier.cpp
You need to enable thread support in the compiler. I think the option is -pthreads on Solaris, but you should check the docs. Anthony -- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
participants (2)
-
Anthony Williams
-
Lars Kunert