This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Static and Dynamic Linking with GCC
- To: Dan Mergens <dan at photon dot com>
- Subject: Re: Static and Dynamic Linking with GCC
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- Date: Fri, 20 Jul 2001 17:44:53 -0400
- Cc: gcc at gcc dot gnu dot org
- References: <3B58A22C.9D84160E@photon.com>
On Fri, Jul 20, 2001 at 02:27:08PM -0700, Dan Mergens wrote:
> For example, in IRIX you can do the following:
>
> CC a.o -B static -lfoo -Bdynamic -lbar
>
> which will link which libfoo.a, libbar.so, and the standard .so's
>
> What is the equivalent gcc command line? (I'm beginning to think it
> doesn't exist).
This is largely (and on many platforms, entirely) a function of the
linker, not the compiler per se. The compiler driver ("gcc" or "g++",
etc) can pass arbitrary (comma-separated) options to the linker with -Wl,
so you need to read the man page for the linker you're using[*], figure out
which options to pass to it, and then feed those to gcc/g++. For example,
on Solaris it's something like
gcc a.o b.o ... z.o -Wl,-B,static -lfoo -Wl,-B,dynamic -lbar
and the linker receives
ld ..... -B static -lfoo -B dynamic -lbar ....
Phil
[*] Run 'gcc --print-prog-name=ld' to get the full path to ld; then you
can investigate that binary and determine which one is in use.
--
Would I had phrases that are not known, utterances that are strange, in
new language that has not been used, free from repetition, not an utterance
which has grown stale, which men of old have spoken.
- anonymous Egyptian scribe, c.1700 BC