Boost logo

Boost :

Subject: Re: [boost] Some library dependency and auto liker issues
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-08-20 12:44:37


On Monday 20 August 2012 18:20:50 Vicente J. Botet Escriba wrote:
> Hi,
>
> there is an issue https://svn.boost.org/trac/boost/ticket/7045 that I
> don't know how to fix.
>
> The problem is related to library dependencies and auto-linker.
>
> * 1st issue: Boost.Threads depends on Boost.DateTime but only for the
> header only part. Anyway, it includes a DateTime file that includes the
> boost/config/auto_link.hpp, and this makes the tools using the auto
> linker to create a dependency on Boost.DateTime. As the Boost.Threads
> build Jamfile doesn't link with Boost.DateTime, the command
>
> bjam toolset=msvc-11.0 --build-type=complete --with-thread
>
> doesn't build the library Boost.DateTime and so when a tool such as Visual
> studio uses the auto linker information, it tries to link with
> Boost.DateTime and not finds it, as not build (even if it is not needed).
>
> What is the best way to fix this?
> Should Boost.Thread link with Boost.DateTime, even if it don't needs it?
> Or just document that the user relaying on auto-linker needs to build
> explicitly the boost_date_time library with the command:
>
> bjam toolset=msvc-11.0 --build-type=complete --with-thread --with-date_time

I think Boost.Thread always depends on Boost.DateTime, at least on Windows. I
see it includes Boost.DateTime in src/win32/thread.cpp.

I think, the dependency on Boost.DateTime should be in the Jamfile of
Boost.Thread. This way the build system will know that Boost.DateTime should
also be compiled when Boost.Thread builds.

> * 2nd issue: Boost.Threads depends on Boost.Chrono and the library is linked
> with boost_chrono. When a user includes for example <boost/thread/tss.hpp>
> the autolinker doesn't detects the chrono dependency as this file don't
> depends on any file in boost/chrono. But as boost_thread depends on
> boost_chrono, the linker find some unresolved symbols.

Does it? I thought Boost.Chrono-related code in Boost.Thread was header-only.
If so, the chrono-related part should probably be disabled by defining
BOOST_THREAD_DONT_USE_CHRONO when Boost.Thread builds.

> What is the best way to fix this?
> Should Boost.Thread include boost/chrono.hpp in all their public files even
> if not needed other than by auto linker tools? Or just document that the
> user relaying on auto-linker needs to include only the top level file
> <boost/thread.hpp> so that all the dependencies are covered?

Please don't do this. I had this problem with Boost.Log, which uses
Boost.Thread but doesn't use Boost.Chrono. I don't want to introduce
dependency on Boost.Chrono, so I explicitly disabled it when Boost.Log
compiles. I would like to keep this dependency optional, if possible.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk