This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Q: linker "-static" flag usage
- To: gcc at gcc dot gnu dot org
- Subject: Re: Q: linker "-static" flag usage
- From: Denis Vakatov <vakatov at peony dot nlm dot nih dot gov>
- Date: Thu, 11 May 2000 17:53:06 -0400 (EDT)
- CC: aoliva at cygnus dot com, hjl at lucon dot org, vakatov at peony dot nlm dot nih dot gov
Thanks,
Alexander and H.J.,
So it looks that I'll have to detect the underlying "ld" at first,
and then apply relevant "-Wl,-FOOdynamic/-FOOstatic".
This is gonna be fun :-).
Then, more questions follow (sorry):
1) Where can I get the path/name of the linker used by "gcc"?
2) Am I right that I should use:
a) for GNU "ld" underlying linker: -Wl,-Bstatic / -Wl,-Bdynamic
b) for SUN "ld" underlying linker: -Wlinker -Bstatic / -Wlinker -Bdynamic
c) for IRIX "ld" underlying linker: mission impossible, "foged-aboud-it"
3) ...and (2a) will switch the linking policy correctly as it
progresses through the library list,
in the sense that e.g.
-Wl,-Bstatic -la1 -Wl,-Bdynamic -la2
would force the link with "liba1.a" and "liba2.so".
?,
Denis Vakatov
-----------------------------------------------------------------------------
> Cc: gcc@gcc.gnu.org
> From: Alexandre Oliva <aoliva@cygnus.com>
> Organization: Cygnus Solutions, a Red Hat Company
> Date: 11 May 2000 17:56:16 -0300
> User-Agent: Gnus/5.0805 (Gnus v5.8.5) XEmacs/21.1 (Canyonlands)
> X-MIME-Autoconverted: from quoted-printable to 8bit by peony.nlm.nih.gov id QAA01615
>
> On May 11, 2000, Denis Vakatov <vakatov@peony.nlm.nih.gov> wrote:
>
> > 1) Will the "-static" flag affect the linking of ALL libs following
> > him in the linker command-line?
>
> This is not a compiler issue, but a linker issue, and the linker is
> not part of GCC. The answer depends on which platform you're using.
> I believe it may even affect libs listed before `-static', on some
> platforms.
>
> --
> Alexandre Oliva Enjoy Guaranį, see http://www.ic.unicamp.br/~oliva/
> Cygnus Solutions, a Red Hat company aoliva@{redhat, cygnus}.com
> Free Software Developer and Evangelist CS PhD student at IC-Unicamp
> oliva@{lsd.ic.unicamp.br, gnu.org} Write to mailing lists, not to me
>
>
-----------------------------------------------------------------------------
> Date: Thu, 11 May 2000 13:47:31 -0700
> From: "H . J . Lu" <hjl@lucon.org>
> Cc: gcc@gcc.gnu.org
>
> On Thu, May 11, 2000 at 03:45:21PM -0400, Denis Vakatov wrote:
> > Hi,
> >
> > Sorry, but I cannot get sufficient info about the use of "-static"
> > flag with GCC. After searching numerous discussions, and looking into
> > your manual(http://gcc.gnu.org/onlinedocs/gcc_2.html#SEC13), and
> > "man gcc", and "gcc -v --help", the only thing I got is:
> >
> > | -static
> > | On systems that support dynamic linking, this prevents linking
> > | with the shared libraries. On other systems, this option has no effect.
> >
> > I need to know an answer to 2 more questions:
> >
> > 1) Will the "-static" flag affect the linking of ALL libs following
> > him in the linker command-line?
>
> No, "-static" applies to ALL libs in the linker command-line.
>
> >
> > 2) If (1) == TRUE, then -- is there a way to restore the default
> > static/dynamic linking policy after you used "-static" flag in
> > your command line (something like the "-Bdynamic" flag for
> > Sun native compiler)?
>
> I have been using
>
> # gcc ... -Wl,-Bstatic -lfoo -Wl,-Bdynamic ...
>
> Only libs between -Wl,-Bstatic and -Wl,-Bdynamic will be linked
> statically. BTW, I am using GNU ld.
>
>
> H.J.
>