Boost logo

Boost-Build :

From: Andre Hentz (ahentz_at_[hidden])
Date: 2004-09-13 10:55:04


Vladimir Prus wrote:
> Hi Andre,
>
>
>>How do I force a library to be linked statically with gcc? By looking at
>>gcc.jam, it seems that <find-static-library> does not enforce static
>>linking.
>
>
> Right, not anymore, because I'm completely unsure how this can be reasonably
> done. I've a couple of question to you:
>
> 1. Why do you need static linking to a specific library?

I need a few wrapper programs to link statically against libstdc++ (or
libsup++). It is part of the specification that they may run on a system
where libstdc++.so is not present.

> 2. One approach is to use:
>
> g++ ..... -Wl,-Bstatic -lwhatever
>
> however this will fail if there's no static version of whatever. Also, there's
> assymentry with:
>
> g++ ..... -Wl,-Bshared -lwhatever
>
> which will link to whatever.so if present, but will also link with whatever.a,
> not fail. Is the '-Bstatic' behaviour what you're after? I'm a bit worried by
> its platform-specificity.

Yes, that's what I have in mind. If I use <find-static-library>, I
expect it to fail if there's no libwhatever.a. In fact, -Bstatic is
linker-specific, not platform-specific. That is also the case for
"-Wl,-R", "-Wl,-h", "-Wl,-rpath-link" and "-Wl,--strip-all". I'm
updating my BB setup and haven't got to solaris yet but I believe
--strip-all is going to cause problems. -rpath-link is also potentialy
problematic but I'm not using it so it's not a biggie.

Perhaps we could configure gcc.jam to use a specific set of linker
options, like:

using gcc : 3.3 : <linker>sun ;

> While we discuss this, you can use
>
> <linkflags>"-Wl,-Bstatic -lwhatever"
>
> to make your project work.
>

I'll try that.

> - Volodya
>

 


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