Lost C Subroutines FOUND

Dick Gill rg at psgdc
Tue Apr 18 02:08:03 AEST 1989


Let me summarize the responses to my posting about the seemingly
missing subroutines when trying to compile/link the slice
utility. 

The responses all pointed to the order of arguments in the cc
statement; specifically, the necessity to put the -lPW argument
at the END of the statement.  When I modified the Makefile
appropriately, the compile/link worked just fine. John Nelson
(uunet!genrad.com!jpn - thanks John) described the problem clearly
as follows:
----------------------------------------------------------------------------

>	cc  -O  -DUSG -lPW -o slice  slice.o
> ...
>Why are these subroutines not being found? Any insights will be appreciated.

Ah, an easy one.  "ld" (which is called by cc) processes object files
and libraries in the order in which they appear on the command line
(even libraries specified with a -lxx flag).  In other words, ld is one
of the exceptions to the rule that all '-' args must appear before the
file args.  In your example, libPW.a is scanned first, and no currently
undefined symbols are found there, so nothing is loaded.  Then slice.o
is loaded, generating undefined symbols.

Try the following:

	cc -O -DUSG -o slice slice.o -lPW

----------------------------------------------------------------------------

Thanks also go to:

          Andrew:   andrew at att.att.com
       Sam Vause:   vause at cs-col.Columbia.NCR.COM
   Johnathan Hue:   uunet!jvc!johnathan
  Stephen Freidl:   uunet!vsi!friedl
  Gordon Burditt:   ...!texbell!sneaky!gordon

(I'm amazed to see this many net members agree on something !:-)



More information about the Comp.unix.questions mailing list