Opened 10 years ago

Closed 9 years ago

#7335 closed Bugs (duplicate)

Using Boost.Pool requires to link with Boost.System

Reported by: Ivan A. Melnikov <iv@…> Owned by: Chris Newbold
Milestone: Boost 1.52.0 Component: pool
Version: Boost 1.51.0 Severity: Problem
Keywords: Cc: flast@…, vslavik@…, bimargulies@…

Description

Boost.Pool documentation says:

The Boost Pool library is a header-only library. That means there is no .lib, .dll, or .so to build; just add the Boost directory to your compiler's include file path, and you should be good to go!

But in fact, in boost 1.51.0 on my system (ALT Linux x86_64) it uses Boost.Thread parts which bring Boost.System in, and thus I get the following linking error:

$ cat a.cpp

#include <boost/pool/pool_alloc.hpp>

int main() { return 0; }

$ g++ a.cpp
/tmp/.private/iv/ccqf3pLa.o: In function `__static_initialization_and_destruction_0(int, int)':
a.cpp:(.text+0x4a): undefined reference to `boost::system::generic_category()'
a.cpp:(.text+0x56): undefined reference to `boost::system::generic_category()'
a.cpp:(.text+0x62): undefined reference to `boost::system::system_category()'
collect2: ld returned 1 exit status

Of course, adding -lboost_system helps.

Not shure if it is Boost.Pool, Boost.Thread or just Boost.Pool documentation bug.

Change History (6)

comment:1 by Kohei Takahashi <flast@…>, 10 years ago

Cc: flast@… added

This bug caused by r76543.

New dependencies tree:

pool/detail/mutex.hpp
-> thread/mutex.hpp
   -> thread/(pthread|win32)/mutex.hpp
      -> thread/exceptions.hpp
         -> system/error_code.hpp

comment:2 by Ivan A. Melnikov <iv@…>, 10 years ago

As far as I know, Boost.Thread never promised to be header-only or have header-only parts. Thus, using mutex from Boost.Thread and claiming to be header-only seems to me... erm... a bit unfair, even if it used to work somehow.

I think the best solution would be to switch to using <boost/detail/lightweight_mutex.hpp>, as it is header only and does not have any extra dependencies.

comment:3 by vslavik@…, 10 years ago

Cc: vslavik@… added

comment:4 by bimargulies@…, 9 years ago

Cc: bimargulies@… added

Is there any way around this to disable the use of the mutex?

in reply to:  4 comment:5 by manuel.freiberger@…, 9 years ago

Replying to bimargulies@…:

Is there any way around this to disable the use of the mutex?

I also stumbled across this bug. The pool library pulls the header <boost/thread/mutex.hpp> even if the user has defined BOOST_NO_MT or BOOST_POOL_NO_MT.

It would be good to change line 13 of <boost/thread/mutex.hpp> from #ifdef BOOST_HAS_THREADS to #if defined(BOOST_HAS_THREADS) && !defined(BOOST_NO_MT) && !defined(BOOST_POOL_NO_MT) (this is the complement of the expression from line 32).

This would allow to use Boost.Pool without depending on Boost.System.

comment:6 by Marshall Clow, 9 years ago

Resolution: duplicate
Status: newclosed

This is a duplicate of #7085

Note: See TracTickets for help on using tickets.