linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shriramana Sharma <samjnaa@gmail.com>
To: Glynn Clements <glynn@gclements.plus.com>
Cc: Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: Re: can't understand linking behaviour
Date: Fri, 15 Jun 2007 09:50:58 +0530	[thread overview]
Message-ID: <467213AA.5070008@gmail.com> (raw)
In-Reply-To: <18011.26062.21505.664418@cerise.gclements.plus.com>

Glynn Clements wrote:
> Libraries can have undefined references. Sometimes this is necessary,
> e.g. if the library depends upon a function which is supposed to be
> provided by the executable.

To my mind, in the real world, if a library must access a function that 
the executable provides, it will only be through a function pointer -- 
the library may provide, for e.g. a binary search facility, and the 
program uses this to carry out a binary search on a function in its body.

What real world application would make a library A to call a function 
foo() when foo() is defined in the body of an executable X that itself 
depends on A? If foo() were in a dependency of A, say library B, then it 
can be understood, but to expect the function to come from X is, 
although *theoretically* possible, how practically necessary?

> gcc -o main main.c -L. -Wl,-rpath-link,. -la

On my system doing the same without the -Wl, command seems to produce 
the same effect. However the symbol is still marked undefined by nm, 
even if I have linked it.

>> This seems highly counter-intuitive. Why would the linker require *only* 
>> at *executable* build-time the libraries,
> 
> Why would the linker require all external symbols to be resolved at
> the time the library is built?

If you prove that there is a valid real-life situation where the library 
needs a symbol from an application, then the linker would not require 
all external symbols to be resolved.

Shriramana Sharma.


  reply	other threads:[~2007-06-15  4:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-27 14:50 can't understand linking behaviour Shriramana Sharma
2007-05-28 23:29 ` Glynn Clements
2007-06-15  4:20   ` Shriramana Sharma [this message]
2007-06-20 14:39     ` Pedro de Medeiros

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=467213AA.5070008@gmail.com \
    --to=samjnaa@gmail.com \
    --cc=glynn@gclements.plus.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 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 NNTP newsgroup(s).