Summary: Problem with "ld" and "ar"

Chyouhwa Chen cchen at sbcs.sunysb.edu
Wed Jun 6 00:12:00 AEST 1990


I asked the following question:

|Sometimes "ld" can't find some of the functions in the libraries, even
|though when I did an "ar -t", the object files containing those functions
|is indeed in them.  The strange thing is that "ld" can find other
|functions defined in the same object files!  I've been manually including
|those object files "ld" is having problems with.  Does anybody know a
|solution to avoid this hassle?

The problem is that "ld" doesn't go back to libraries it had examined
already.  So the explanation of the above behavior of "ld" is that 

1. It resolved only those references it needs at the time in a file F when
   examining some library,
2. It moved forward,
3. A reference is made in a later library to some other symbols in F,
4. Lots of Undefined _??? messages,

So it is important to order the libraries so that there is no backward
symbol references *between* libraries.  But when you have a huge program,
how are you going to keep track of who calls who between libraries?  Well,
you don't have to.  Just specify the libraries on the command line
multiple times, and let "ld" do it.

Thanks guys.

- Chyouhwa
  cchen at sbcs.sunysb.edu



More information about the Comp.sys.sun mailing list