From: Shriramana Sharma <samjnaa@gmail.com>
To: cyon.john@wipro.com
Cc: linux-c-programming@vger.kernel.org
Subject: Re: unable to link to a static library present alongside a shared library
Date: Wed, 18 Apr 2007 23:04:21 +0530 [thread overview]
Message-ID: <4626569D.7000200@gmail.com> (raw)
In-Reply-To: <70661EB74D51BD4889EE03CC34E733F5A766BA@blr-m2-msg.wipro.com>
cyon.john@wipro.com wrote:
> That "-shared -static" option becomes relevant when both libgoo.so and
> libgoo.a are present. By default, libfoo.so will be dynamically linked
> with libgoo.so and will be a dependency. But if used "-static" along
> with "-shared" while creating libfoo.so, then it will be statically
> linked with libgoo.a and won't have a dependency on libfoo.so.
You are talking about the ordinary behaviour. -static always is used to
mandate linking to a static lib and deny linking to a shared lib.
Whether the target being built is an executable or a shared lib is
immaterial.
> I was not able to see such a statement in the man pages in my system !!!
Dunno why. I'm using Kubuntu Edgy and my binutils version is
2.17-1ubuntu1. The statement about using -shared and -static together is
there in the documentation for the -static option (end of the paragraph)
and is probably intended to clarify to the users that -static and
-shared are not conflicting and only -static and -call_shared are
conflicting. It could be rewritten.
> I tried 'gcc -shared -static -o libfoo.so foo.c -L . -lgoo', but the
> output libfoo.so was dynamically linked with libgoo.so though libgoo.a
> was present.
>
> Then after some googling, I tried 'gcc -shared -Wl,-static -o libfoo.so
> foo.c -L . -lgoo -nostdlib' and it gave me libfoo.so which is statically
> linked with libgoo.a.
What's the difference? gcc will transparently pass on the -static option
to ld if I read my man:gcc page right, and -nostdlib is to prevent
linking to standard system libraries which libgoo is certainly not! How
do the two commands give a different effect?
Shriramana Sharma.
next prev parent reply other threads:[~2007-04-18 17:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-18 12:09 unable to link to a static library present alongside a shared library Shriramana Sharma
2007-04-18 12:19 ` cyon.john
2007-04-18 12:33 ` Shriramana Sharma
2007-04-18 14:00 ` cyon.john
2007-04-18 17:34 ` Shriramana Sharma [this message]
2007-04-18 15:12 ` Glynn Clements
2007-04-18 18:40 ` Shriramana Sharma
2007-04-18 20:18 ` Glynn Clements
2007-04-19 10:10 ` Shriramana Sharma
2007-04-19 12:34 ` leslie.polzer
2007-04-19 13:48 ` Shriramana Sharma
2007-04-19 16:30 ` leslie.polzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4626569D.7000200@gmail.com \
--to=samjnaa@gmail.com \
--cc=cyon.john@wipro.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.