C/Unix Libraries

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Dec 4 15:02:51 AEST 1988


In article <18524 at shemp.CS.UCLA.EDU> kirkaas at cs.ucla.edu (paul kirkaas) writes:
>Is there any way to look at a library or object file & tell what routines
>are defined in it?  "nm" seems only to tell what symbols appear
>in an object file; not whether they are defined there or not.

Since I don't know your specific C system, all I can give is generic
UNIX advice.  All flavors of "nm" I'm familiar with do show the
difference between the definition of a symbols and a reference to it.

>I particularly find this a problem when I port complex programs & get
>a lot of link time undefined symbol errors.

Most linkers I know of have an option to trace def of/ref to a symbol
during linking.  (On VAX 4.3BSD it's "ld -y symbol".)  System V "cc"
should support the -# option, which prints the commands that would be
executed to do the real compilation/linking ("cc" itself is just a
driver).  So add -# to your link command line, then on your 630, or
using EMACS, or whatever, edit the displayed result to include
-y symbol (or whatever option your manual says to use on the "ld"
command line), then send the edited result as a manual "ld" command.
(If you don't have a decent interactive environment you'll have to
type this in by hand.)  "ld" should show clearly where the references
to the symbol are being made.



More information about the Comp.lang.c mailing list