Linking Error of Undefined Ref in the static lib

M

micropentium

Yes. If you think about what's going on under the hood, if you're
linking statically then each library function used by your program
needs to be copied into your executable. To avoid bloating the
executable, it makes sense only to include those functions that you
actually use. Of course, the linker *could* go back through the -l
arguments if there are still unresolved symbols after it's processed
them in order. I don't know why it doesn't.

For shared libraries, when your program starts up, the entire externally
visible symbol table of the library will be available, so there's no
reason for the compiler not to remember all the symbols when it sees
them - whether you use or don't use a function from the library in your
code makes no difference at all to the size of the executable.


I don't know - why don't you suggest it to them?

AT:

Thank you for answering my question! I really appreciate your help and
patience.
 
E

Ersek, Laszlo

For shared libraries, when your program starts up, the entire externally
visible symbol table of the library will be available,

I'm not sure. (Or I don't understand what you mean.)

$ man ld-linux

ENVIRONMENT
LD_BIND_NOW
If present, causes the dynamic linker to resolve all
symbols at program startup instead of when they are
first referenced.

http://www.opengroup.org/onlinepubs/9699919799/functions/dlopen.html

----v----
RTLD_LAZY

Relocations shall be performed at an implementation-defined time,
ranging from the time of the dlopen() call until the first reference to
a given symbol occurs. Specifying RTLD_LAZY should improve performance
on implementations supporting dynamic symbol binding as a process may
not reference all of the functions in any given object. And, for systems
supporting dynamic symbol resolution for normal process execution, this
behavior mimics the normal handling of process execution.

RTLD_NOW

All necessary relocations shall be performed when the object is first
loaded. This may waste some processing if relocations are performed for
functions that are never referenced. This behavior may be useful for
applications that need to know as soon as an object is loaded that all
symbols referenced during execution are available.
----^----

The dlopen() specification describes the symbol resolution algorithms as
well (load ordering and dependency ordering).

Cheers,
lacos
 
R

Richard Bos

Mark Bluemel said:
You can't build or run a C program without [...] coffee

I don't drink coffee. Time for a flame war about the superiority of
tea, methinks.

Any Briton, Chinese, Taiwanese or Japanese who prefers coffee to tea is
doomed to eternal damnation. Any non-Englishman who prefers coffee to
tea is merely a fool.

Richard
 
J

James Dow Allen

Would it not be non-topical for me to write:

You can't build or run a C program without [...] coffee

OP had a *very* simple question very closely related to C.
Mr. Twink gave him the very simple correct answer. This
could have been a 2-message thread (or 3 messages counting
OP's thank you).

Instead we got a dozen non-topical posts about non-topicality
(or topical only in the sense that discussion of non-topicality
is never non-topical: I've made my own non-topical post topical
with the 1-line non-topicality disclaimer that begins this post).

Ignoring that OP was actually ... er ... topical(!) the non-topicaliy
complaints might be purposeful if they actually led to a reduction
in non-topicality. Instead the topical non-topicaliticans
*know* they'll be ignored, so their efforts only lead to an
*increase* in non-topicality!
(For that matter, I used to work with a Mormon programmmer - anyone
for a nice cup of Carob?)

Religion? Oh, that's *always* topical here!

James
 
A

Antoninus Twink

Instead the topical non-topicaliticans *know* they'll be ignored, so
their efforts only lead to an *increase* in non-topicality!

Yes - but they aren't operating on a rational level, so I predict that
your arguments will not penetrate in the slightest.
Religion? Oh, that's *always* topical here!

Heathfield certainly thinks so - he's got form when it comes to
introducing references to the bible into technical discussions.
 
P

Phil Carmody

Mark Bluemel said:
You can't build or run a C program without [...] coffee

I don't drink coffee. Time for a flame war about the superiority of
tea, methinks.

Any Briton, Chinese, Taiwanese or Japanese who prefers coffee to tea is
doomed to eternal damnation. Any non-Englishman who prefers coffee to
tea is merely a fool.

I guess in our little corner of the office there are about 40 linux
kernel hackers, or people so closely connected to kernel hacking that
the distinction's unimportant (the architects wrote the drivers we
now maintain, for example).

And amongst linux kernel hackers, in the home of linux - the 2nd most
heavy coffee-drinking nation in the world, I guess there are at least
two tea drinkers to every coffee drinker.

Phil
 
R

Rich Webb

I guess in our little corner of the office there are about 40 linux
kernel hackers, or people so closely connected to kernel hacking that
the distinction's unimportant (the architects wrote the drivers we
now maintain, for example).

And amongst linux kernel hackers, in the home of linux - the 2nd most
heavy coffee-drinking nation in the world, I guess there are at least
two tea drinkers to every coffee drinker.

For another data point, I drink tea when coding (embedded military and
high reliability systems) because I really hate the taste of old, room
temperature coffee when I come up out of the zone for a sip.

Tea that has cooled to ambient, on the other hand, is still pretty good.
So, sippity sip and back to work rather than trudge out to the coffee
mess for a fresh cup of coffee.
 
R

Richard Bos

Gareth Owen said:
As a coffee loving British non-Englishman, I am now mightily confused.

You may blame that on my starting out with a stereotypical Englishman,
and considering halfway through that there are others who are even more
entitled to the title of tea-drinker /par excellence/.
Am I a doubly doomed fool, or do I get a double-negative loophole. :)

That depends. I know that the Irish are almost and the Scots not quite
as tea-expertised as the Sais, but I know little or nothing of the
bibulous habits of the Welsh, as I assume you from your name to be.

Richard
 
G

gwowen

That depends. I know that the Irish are almost and the Scots not quite
as tea-expertised as the Sais, but I know little or nothing of the
bibulous habits of the Welsh, as I assume you from your name to be.

We exist solely on coal, Brains Beer and the charitable munificence of
Russell T. Davis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top