PDA

View Full Version : Generating a profile for a C++ program


ateles
04-20-2002, 07:31 PM
I have been trying to generate a profile for a C++ program by typing:

c++ -pg test.cpp

The very first time I did this, the file gmon.out was created so I typed:

gprof

and it return an error like "can't read gmon.out, file is truncated"

I recompiled again to try it once more and this time the file gmon.out was not created, and it has never been created since (I have recompiled with the -pg option many, many times in different directories and with different source files). Anybody knows how to solve this?

Thanks,
:(

ateles
04-21-2002, 05:19 PM
I figured it out! For those interested:

1) compile the program with the -pg option (e.g 'c++ -pg test.cpp')
2) then run it!
3) then type gprof

that should do it.

:D