Boost logo

Boost-Build :

From: Tomas Puverle (Tomas.Puverle_at_[hidden])
Date: 2006-06-16 14:36:32

> I'm not recommending this, but Sun makes it impossible to link a 100%
> static
> binary on Solaris 10. You can (with care) link with static versions
> your
> own and third-party libraries, but there are simply no static versions
> the system libraries provided.

Yes, that's correct. The reason for static linking is that in our a
large distributed environment, most shared libraries live in a
distributed filesystem (NFS/AFS) but for some applications we can't
afford for them not to start up should there be a file server outage.
Since the system libraries live on the same machine as the app, the only
way for them to break for the root filesystem become inaccessible, which
then becomes a completely different problem :)

> Sun's linker, I believe, supports using both -Bstatic and -Bdynamic on
> same link line, so you can choose to link some libraries staticly and
> others
> dynamically,


> but with GNU ld it seems like these flags are all-or-none:

That shouldn't be the case.

> gcc -L. -o hello-static -Bstatic hello.o -lgreet -Bdynamic
> % ldd hello-static
> => ./
> => /lib/
> => /lib/
> So even though I've tried to request static linking for -lgreet, I've
> gotten
> the shared version. I believe this is because the -Bdynamic at the
end of
> the command line overrides the earlier -Bstatic so the entire link is
> performed using dynamic libraries.

This is very strange. This is what I do all the time and it works as
you'd expect. Which version of g++ are you using? I am also wondering
if the hello.o inside the -Bstatic section is confusing it...

> So this is almost right. I think that the -static needs to move
> the
> "group" and after the group must come, paradoxically, -Wl,-dy. Then
> libraries mentioned inside the --start-group/--end-group pair would be
> linked staticly and the system libraries which are pulled in
> would be dynamically linked.

Yes, that sound like the right idea. However, there is one more
complication - what if the shared objects depend on symbols from the
statics? In that case, you will need multiple groupings.

> For my testing, I have a simple brute-force workaround in place that
> eliminates the use of -static altogether. This addresses these
> testing issues for me, but I think this issue might bear some further
> discussion.

Yes, I agree. I think the best way forward would be to have -Bstatic
-Bdynamic pairings. I'm not sure why it's not working for you.



Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at