Boost logo

Boost-Build :

Subject: Re: [Boost-build] Dependency on shared library from static library(mixing shared and static libs)
From: Alexander Sack (pisymbol_at_[hidden])
Date: 2009-02-03 13:31:08


On Tue, Feb 3, 2009 at 12:30 PM, Johan Nilsson
<r.johan.nilsson_at_[hidden]> wrote:
> Alexander Sack wrote:
>>
>> On Tue, Feb 3, 2009 at 8:21 AM, Johan Nilsson
>> <r.johan.nilsson_at_[hidden]> wrote:
>>>
>>> Hi,
>>>
>>> consider the following:
>>>
>>> - Library "a" that can be built for shared or static linking.
>>> - Library "b" depends on "a", but can only be built for static
>>> linking.
>>> - App "c" depends (directly) on "b".
>>>
>>> All the above are defined as Boost.Build targets within a single
>>> project.
>>>
>>> I would like to be able to:
>>>
>>> 1. Build app "c" to use the shared version of "a" (e.g. bjam
>>> link=shared):
>>> - Link statically to "b" (as this is the only possibility)
>>> - Link shared to "a"
>>> - Lib "b" should reference the shared build of "a"
>>
>> Well I believe static libb can't be linked with shared a.
>
> Well, obviously a static lib can't be linked (at least not with msvc). Hence
> the "... _reference_ the shared build of a" (which could be even more
> specific by stating "contains references to the functions exported by the
> shared build of a", perhaps).
>
>> That
>> doesn't make sense to me. See here for more linkage info with respect
>> to Boost.Build:
>>
>> http://www.boost.org/doc/tools/build/doc/html/bbv2/tutorial/linkage.html
>>
>>> 2. Build app "c" to use the static version of "a" (e.g. bjam
>>> link=static):
>>> - Link statically to "b"
>>> - Link statically to "a"
>>> - Lib "b" should reference the static build of "a"
>>
>> This is what I did with your Jamroot and got results which I *think*
>> are what you want:
>>
>> project foo ;
>>
>> # can be built as static or shared library
>> lib a : a.cpp : <link>shared:<define>A_BUILD_DLL : :
>> <link>shared:<define>A_BUILD_DLL ;
>
> That is most definitely not what I want (your modified usage requirements).

whoops, cut and past typo. Change it back.

> I'm a bit surprised that you managed to build the unmodified sources using
> gcc - is that really a fact? Please note though, that using shared libraries
> under windows is a different beast than under linux using gcc.

Yes I did have to modify liba I think with the ifdef's for the symbol
qualifier you are trying to add. That was it. I didn't think it was
pertinent to the problem at hand.

Do you still have the issue though?

-aps


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