Boost logo

Threads-Devel :

Subject: Re: [Threads-devel] undefined reference to `boost::thread_resource_error::thread_resource_error()'
From: Anthony Williams (anthony_at_[hidden])
Date: 2010-06-18 04:26:52


On 18/06/10 08:52, simon h wrote:
> With boost_1_43_0 built and installed from source on a clean ubuntu
> machine I get link errors when compiling my code:
>
> .build/debug/magna/.singleunit.o: In function `recursive_mutex':
> /usr/include/boost/thread/pthread/recursive_mutex.hpp:46: undefined
> reference to `boost::thread_resource_error::thread_resource_error()'
> ...
> .build/debug/magna/.singleunit.o:/usr/include/boost/thread/pthread/recursive_mutex.hpp:57:
> more undefined references to
> `boost::thread_resource_error::thread_resource_error()' follow
> collect2: ld returned 1 exit status

This is most bizarre.

> In my case, the link errors were resolved by preceding my inclusion of
> recursive_mutex by include boost thread exceptions:
> #include <boost/thread/exceptions.hpp> // <--- add this line before
> #include <boost/thread/recursive_mutex.hpp>

That should be unnecessary --- the recursive mutex header already
includes boost/thread/exceptions.hpp

> This seems sub-optimal to me. Shouldn't the recursive mutex header be
> self contained??

Yes it should be (and appears to be to me).

> Am I missing something? I think in previous versions of boost thread,
> 1.38 at least, I can see that constructors for recursive_thread_error in
> the library & good for linking without extra include.

In previous versions the exception constructors were out-of-line, and in
the library. In 1.43 they are inline in the headers. I don't understand
why including the header explicitly fixed the problem, since it should
already be included. I don't see the problem here on Ubuntu.

Anthony

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Threads-Devel 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