RE: ld -static option.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-static tells the compiler to link all libraries following that option
statically.  If you don't tell the linker to link dynamically by default
at some point after using this option (using -Bdynamic or something
similar), then it will link _all_ libraries listed after -static
statically, including libraries that normally get linked in by default,
such as the C library, etc. Generally, if you only want a specify
library linked in statically, you would do something like this:

gcc -o a.out a.o -static -L. -lmylib -Wl,-Bdynamic

The actual argument to use to tell the linker to link dynamically may be
different depending on the platform you're building on.

Cheers,
Lyle

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On
Behalf Of Bansidhar Arvind Deshpande - CTD, Chennai.
Sent: Tuesday, November 18, 2003 4:05 AM
To: gcc-help@xxxxxxxxxxx
Subject: ld -static option.

Hi all,

I am using gcc 2.96. I am wondering the working of -static option given
for
ld. What is the exact functionality of this. 
e.g 
     ld a.o -static -L./ -lmylib -o a.out

In above example does the -static option apply only for mylib which is
specified
by -l or it is applied for all of the libraries to generated a.out.
Generically 
does -static controls only to the libraries specified by -l or all of
the
libraries
taken by ld to generate the executable ? 
I am also interested in hidden functionality of -static if exists. 

Thanks,

--Bansidhar


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux