Boost logo

Boost Users :

Subject: Re: [Boost-users] [Program Options] Linking both statically and dynamically
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-05-15 20:18:53


On Wed, May 12, 2010 at 11:28 AM, Anthony Foglia <AFoglia_at_[hidden]> wrote:
> OvermindDL1 wrote:
>>
>> As far as I know (which should be 'enough'), for libraries like that,
>> any mixing of static and dynamic linking *will* break.  The only way
>> to work around it is for the main application to be static, but have
>> the other libraries dynamically link to the static version in the main
>> application, and *not* to the system library, that can be done, but it
>> requires a bit of working around.
>
> (The following is no longer about boost, so feel free respond privately or
> send me somewhere else.)

I still think this is useful for such libraries.

On Wed, May 12, 2010 at 11:28 AM, Anthony Foglia <AFoglia_at_[hidden]> wrote:
> I don't quite follow.  First, what do you mean by "libraries like that?"
>  Does that mean it would work for (some) other libraries?  How do I know
> what type?

By type I mean a library that is designed to be dynamic due to
managing memory or other resources. With these libraries it matters
not where the code actually is, as long as *all* translation units
link to that one and only one code location, whether it be an external
library, the main app, whatever.

On Wed, May 12, 2010 at 11:28 AM, Anthony Foglia <AFoglia_at_[hidden]> wrote:
> Also, the main application is linked statically to some libraries (our
> libraries) and dynamically to others.  Ignoring other libraries, we have
>
> executable both
>  statically linked to our utilities which is statically linked to program
> options
>  dynamically linked to program options.
>
> What I set up yesterday was to change this t
>
> executable
>  statically linked to our utilites which is statically linked to program
> options
>  statically linked to program options
>
> What you're describing, if I read it correctly is
>
> executable
>  statically linked to our utilites which is dynamically linked to the copy
> of program options in the executable
>  statically linked to program options
>
> That doesn't make much sense to me.  (I doubt it's what we want anyway.)
>
> I think another solution, if it's possible would be
>
> executable
>  statically linked to our utilities which is dynamically linked to program
> options
>  dynamically linked to program options
>
> but I'm not sure you can have a static library that links dynamically to
> another library.
>
> I'd like to figure out what the possibilities are before I take this to the
> boost-build list to ask how best to configure it.

What you want is to statically link in program options in one of the
libraries, does not matter whether the main executable or another of
the dynamic libraries, but make sure that *all* others dynamically
link to whatever you statically linked it to, do note, do not dynamic
link to boost program options, just dynamically link to the the the
library that you statically linked it in. If running on Windows then
you might need to make some changes to dllexport things properly
though. You might even just take all of what program option makes
into a library and just stuff it directly into one of your libraries,
as long as the memory is all managed in one and only one place.


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