This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Q: linker "-static" flag usage
- To: Denis Vakatov <vakatov at peony dot nlm dot nih dot gov>
- Subject: Re: Q: linker "-static" flag usage
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Thu, 11 May 2000 13:47:31 -0700
- Cc: gcc at gcc dot gnu dot org
- References: <200005111945.PAA01480@peony.nlm.nih.gov>
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.