|
Boost Users : |
From: George A. Heintzelman (georgeh_at_[hidden])
Date: 2002-03-22 09:47:41
> That's a bug that's been partly fixed in the latest cvs source -
> the -pthread flag should be -pthreads.
>
> However that's not the end of it, because the std lib that ships with gcc on
> solaris has a problem with std::runtime_error when you build with -pthreads
> (basically the code doesn't link because the body of
> runtime_error::runtime_error is missing in the headers), I don't know what
> the solution to this is, other than to fix your std lib (or maybe use
> STLPort).
>>
>> I have downloaded Boost and am trying to build the libraries on
Solaris
>> 8 with g++ 2.95.3:
>>
I ran into this problem just recently. I think John's diagnosis is
incorrect. In fact, stdexcept includes the body of runtime_error just
fine, and the class runtime_error exists.
Part of the problem is that the gcc standard library, when compiled
under -pthreads, typedefs std::string (and all the other default
std::containers) differently from how it is defined under
single-threaded compilation. The default allocator is defined to be:
typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc;
where __NODE_ALLOCATOR_THREADS is a #define which is true if threading
is enabled, false otherwise.
This in itself is still not the real problem. The problem is that the
constructor of runtime_error, and all the other stdexcept classes, is
not actually compiled under pthreads, because stdexcept has a #pragma
interface "stdexcept" line in it which inhibits the compiler from
emitting the bodies of these inline functions. Which it also does in
non-threaded compiling mode, but in that mode the gcc writers have
conveniently put the non-threaded definitions into the libstdc++, so
your link works fine.
I think there is a workaround: put
#pragma implementation "stdexcept"
in one of of your source files which includes <stdexcept>. This will
cause those bodies to be emitted and your link should go fine.
I haven't tested it myself for various local technical reasons, but I
think it will work.
Good luck, and let me know if it works! If it does, we should maybe
propose that the boost Threads library include such definitions under
gcc.
George Heintzelman
georgeh_at_[hidden]
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net