From: Andrew Haley <aph@redhat.com>
To: "Tayade, Nilesh" <Nilesh.Tayade@netscout.com>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: Query related to library linking.
Date: Mon, 20 Aug 2012 20:22:00 -0000 [thread overview]
Message-ID: <5032269C.5040409@redhat.com> (raw)
In-Reply-To: <742998C661BDD3408828420187AB7B8D02E966@bosmb1.netscout.com>
On 08/20/2012 05:53 AM, Tayade, Nilesh wrote:
> I have a basic query related to linking of static and dynamic libraries.
>
> My program needs to use 'libcrypto', libssl and libnetsnmp libraries.
> Out of these, the libnetsnmp and libssl have dependency on libcrypto.
> For some reason, I need to link the libcrypto and libssl statically to my program.
> So I have built libcrypto.a and libssl.a and I am able to link them correctly.
>
> But when libnetsnmp gets linked, since it is a shared object, it also links libcrypto.so.
> So why should libnetsnmp again try to link libcrypto.so when the symbols are already resolved while statically linking libcrypto.a?
Because libnetsnmp has a run-time dependency on libcrypto, not a compile-
time dependency.
> Is there some way to avoid it? I tried using -static and -Bstatic.
It's going to be very difficult. C has a "One Definition Rule" which
says that in any running program there must only be one definition of
each symbol. Clearly, what you're trying to do will violate that
rule.
I would seriously try to find a way to link your program against
libcrypto.so.
Andrew.
prev parent reply other threads:[~2012-08-20 11:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-20 7:46 Tayade, Nilesh
2012-08-20 20:22 ` Andrew Haley [this message]
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=5032269C.5040409@redhat.com \
--to=aph@redhat.com \
--cc=Nilesh.Tayade@netscout.com \
--cc=gcc-help@gcc.gnu.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 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).