Option -static

Ian Lance Taylor iant@google.com
Thu Jan 7 17:57:00 GMT 2010

Takis Psarogiannakopoulos <takis@XFree86.Org> writes:

> On Thu, 7 Jan 2010, Jakub Jelinek wrote:
>> You can use -Bstatic -la -lb -ld -Bdynamic -le
>> to link liba.a, libb.b, libd.a and libe.so (or libe.a if libe.a doesn't
>> exist).
> You are right, in my example,  but in general that means that you have
> specific knowledge of which libs are static and which are in dynamic form
> in the system.
> I was thinking over a more wide approach where a certain lib doesnt not
> exists on static form and of course you would still want the final linking to
> take place right? In such a scenario if the ld decides by itself to use
> what is available (prinitng a warning) violating the -static option seems
> to me not that much wrong.
> Anyway if thats the case withthe  out of the box gnu ld maybe gold hould
> stick with it too.

The -static option in the absence of -Bdynamic means to do a fully
static link.  People have good reasons to want to do fully static
links, and they do not want to suddenly wind up with a non-static
binary, even if the linker gives a warning.  We should not change the
meaning of -static.

What you want is a different, currently nonexistent, option which
means "when searching for -lNAME, prefer libNAME.a to libNAME.so".


More information about the Binutils mailing list