public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: ld -static option.
@ 2003-11-18 18:26 lrtaylor
  0 siblings, 0 replies; 3+ messages in thread
From: lrtaylor @ 2003-11-18 18:26 UTC (permalink / raw)
  To: bansidhara, gcc-help

-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@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Bansidhar Arvind Deshpande - CTD, Chennai.
Sent: Tuesday, November 18, 2003 4:05 AM
To: gcc-help@gcc.gnu.org
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ld -static option.
  2003-11-18 11:05 Bansidhar Arvind Deshpande  - CTD, Chennai.
@ 2003-11-18 13:25 ` Ian Lance Taylor
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2003-11-18 13:25 UTC (permalink / raw)
  To: Bansidhar Arvind Deshpande - CTD, Chennai.; +Cc: gcc-help

"Bansidhar Arvind Deshpande  - CTD, Chennai." <bansidhara@ctd.hcltech.com> writes:

> 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 ? 

The description of linker options may be found here:
    http://sources.redhat.com/binutils/docs-2.12/ld.info/Options.html#Options

The description of -static says this:

    Do not link against shared libraries. This is only meaningful on
    platforms for which shared libraries are supported. The different
    variants of this option are for compatibility with various
    systems. You may use this option multiple times on the command
    line: it affects library searching for -l options which follow it.

I believe that answers your question.

> I am also interested in hidden functionality of -static if exists. 

I don't understand this question.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* ld -static option.
@ 2003-11-18 11:05 Bansidhar Arvind Deshpande  - CTD, Chennai.
  2003-11-18 13:25 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Bansidhar Arvind Deshpande  - CTD, Chennai. @ 2003-11-18 11:05 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-11-18 18:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-18 18:26 ld -static option lrtaylor
  -- strict thread matches above, loose matches on Subject: below --
2003-11-18 11:05 Bansidhar Arvind Deshpande  - CTD, Chennai.
2003-11-18 13:25 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).