Boost logo

Boost-Build :

Subject: Re: [Boost-build] Need help with an odd <link>shared error
From: Jürgen Hunold (juergen.hunold_at_[hidden])
Date: 2011-08-22 04:03:52


Hi Bob,

On Wednesday, 17. August 2011 19:39:12 Bob Walters wrote:
> I have a project (with its own Jamroot) which builds a library that is
> dependent on several boost libraries. Here's the Jamroot:

> lib stldb
>
> : src/logging.cpp
>
[ snip unimportant parts ]
> libboost_serialization
> libboost_filesystem
> libboost_thread
> libboost_system
> libboost_date_time
>
> : <link>shared:<define>BOOST_STLDB_DYN_LINK=1
>
> ;
 
> When I run this with either link=shared or link=static on Posix
> systems (Linux, MacOS, and Solaris) the build works fine.
>
> When I do bjam link=static on windows, it's also fine, however, when I
> attempt bjam link=shared, I am getting an odd error about not being
> able to open the serialization library.
>
> command line: bjam toolset=msvc link=shared threading-multi variant=debug
> -q result:
> msvc.link.dll bin\msvc-9.0\debug\address-model-32\threading-multi\stldb.dll
> LINK : fatal error LNK1104: cannot open file
> 'libboost_serialization-vc90-mt-gd-1_40.lib'

that is the static serialization library being pulled in by autolinking.

> I don't think that the link error means that it can't find the file
> (because I can see it there in the filesystem under the bin.v2 staging
> directory). I'm wondering instead if there is something specific to
> windows that I have overlooked which is causing this. For example, is
> there a known limitation that the serialization library doesn't
> supporting dynamic linking on windows, and thus no suitable library
> for the link could be found.
>
> I tried, just as an experiment, seeing if I could build the stldb
> library with the static version of serialization via:
>
> alias libboost_serialization : /boostroot//serialization/<link>static ;
>
> That seemed to allow the link to proceed.

That works as expected.

> I also saw some of the past trac issues which suggested adding
> <define>BOOST_ALL_NO_LIB to the project requirements
> (https://svn.boost.org/trac/boost/ticket/4893 and
> https://svn.boost.org/trac/boost/ticket/4901). That also seemed to
> allow the link to complete.

Yes, this effectively disables autolinking for all libraries. This is the way
to go when using b2 (bjam).

> I'm trying to figure out if one of those approaches is what I should
> be doing, or whether I'm just setting myself up for other problems.
> Ideally, I would like to link with a dynamic version of lib
> serialization (i.e. a version build with the same bjam parameters) and
> not have to step around it this way, and I'm a bit confused as to why
> this is only an issue on a windows machine.
>
> I am using boost-jam-3.1.18-1-ntx86 with an older 1_40_0 boost library
> which I have in source form, and have built using "bjam toolset=msvc
> --with-system --with-serialization --with-thread --with-filesystem
> --with-date_time --build-type=complete variant=debug stage"

Looks good.

> Incidentally, I do need a dynamic library (specifically), as I'm
> trying to dynamically load this via the native interface of scripting
> languages. No option to go purely static.

Sounds reasonable.

> Any help or clarification on what I may be doing wrong greatfully
> appreciated. - Bob

Just define BOOST_ALL_NO_LIB and you should be fine on all platforms.

Boost.Build uses this setting itself for building the libraries. (See
BOOST_ROOT/Jamroot).

Hope this helps,

Yours,

Jürgen

-- 
Dipl.-Math. Jürgen Hunold       | IVE mbH
Software-Entwickler             | Lützerodestraße 10 
Tel: +49 511 897668 33          | 30161 Hannover, Germany
Fax: +49 511 897668 29          | http://www.ivembh.de
juergen.hunold_at_[hidden]        | 
                                | Geschäftsführer:
Sitz des Unternehmens: Hannover | Univ.-Prof. Dr.-Ing. Thomas Siefer               
Amtsgericht Hannover, HRB 56965 | PD Dr.-Ing. Alfons Radtke  

Boost-Build 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