[comp.unix.questions] **** a question on gprof ****

siping@cathedral.cerc.wvu.wvnet.edu (Siping Liu) (08/30/90)

I am trying to use gprof to analyze my C program. However,
the linker tells me "Undefined symbol: mcount" after I put
in -p as a C flag. What lib/header files I need to add in?

Please also tell me your experience/comments on using this facility.

Thanks a lot.

siping@cerc.wvu.wvnet.edu

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/31/90)

In article <727@babcock.cerc.wvu.wvnet.edu> siping@cathedral.cerc.wvu.wvnet.edu (Siping Liu) writes:
>the linker tells me "Undefined symbol: mcount" after I put
>in -p as a C flag. What lib/header files I need to add in?

NO changes to the source code whould be required.
However, for profiling, you should specify -p to the "cc" command
that does the linking as well as to the ones that do the compiling.
(Actually, if you leave it out the objects should still link but no
profiling output will be obtained.  It sounds like the C run-time
implementor goofed here.)

gprof may require -pg or some other silly flag instead of the usual -p.