[comp.lang.c] C/Unix Libraries

kirkaas@oahu.cs.ucla.edu (paul kirkaas) (12/03/88)

AT&T System V Unix --

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.

I particularly find this a problem when I port complex programs & get
a lot of link time undefined symbol errors.
Paul Kirkaas
kirkaas@cs.ucla.edu

gwyn@smoke.BRL.MIL (Doug Gwyn ) (12/04/88)

In article <18524@shemp.CS.UCLA.EDU> kirkaas@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.