View the Most Wanted LQ Wiki articles.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-06-2005, 10:56 PM   #1
LQ Newbie
Registered: Jun 2004
Location: bangalore
Posts: 9

Rep: Reputation: 0
gprof: gmon.out: not in a.out format

i having problem with using GPROF ,
i compiled my programme with -pg option ,it created file gmon.out file
but when i tried using command

gcc -g -pg -Wall scan.c -o scan
gprof -b gmon.out > LOG

it giving this error

gprof: gmon.out: not in a.out format

how do i use gprof with ELF

Thanks in advance
eSpark Infotech
Old 01-07-2005, 06:27 PM   #2
LQ Newbie
Registered: Dec 2004
Posts: 16

Rep: Reputation: 0

first off, gmon.out is created when you run the program, not when you compile it.
Now, to run gprof, you need 2 things, an executable, and gmon.out file created
after you've ran the executable at least once (you can run it many times and it
will accumulate the results). Once you get those 2 files, do:

% gprof scan gmon.out

If you don't specify any arguments, gprof will assume executable name
is 'a.out' and profile name is 'gmon.out', but their order is significant. In your
case, gprof thinks that gmon.out is your executable, and so it chokes.
Old 01-07-2005, 11:42 PM   #3
LQ Newbie
Registered: Jun 2004
Location: bangalore
Posts: 9

Original Poster
Rep: Reputation: 0
hello stanleyg76

Thanks for u r reply,i tried the same way u had replied
it gave an error
gcc -g -pg -Wall scan.c -o scan
gprof scan gmon.out > LOG
gprof: gmon.out file is missing call-graph data

plz help me

Thanks in advance
Old 01-10-2005, 06:15 PM   #4
LQ Newbie
Registered: Dec 2004
Posts: 16

Rep: Reputation: 0
Note: The -pg option must be part of your compilation options
! as well as your link options. If it is not, when you run gprof
! you will get no profile report and an error message like this:

gprof: gmon.out file is missing call-graph data

If you run the linker ld directly instead of through a compiler
such as gcc, you may have to specify a profiling startup file
gcrt0.o as the first input file instead of the usual startup
Old 04-15-2005, 05:52 AM   #5
LQ Newbie
Registered: Apr 2005
Posts: 1

Rep: Reputation: 0
Still error not in a.out format

hello stanleyg76,

i have tried even the last version:

gprof my_executable gprof > gprof.output

but it still gives an error
gprof: my_executable: not in a.out format

the gprof version is 2.15

i have already googled a bit, but couldn't find any other plausible info on this error.

thanks in advance,
Old 08-15-2005, 08:19 AM   #6
LQ Newbie
Registered: Aug 2005
Location: Taiwan
Posts: 1

Rep: Reputation: 0
Question gmon.out appearing

I'm new to this forum. I just noticed gmon.out appearing on my Mac Hard Disk. I don't know where it came from. Can I delete it? I'm running 10.3 on an iMac G5.
Old 08-15-2005, 02:09 PM   #7
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Yes, you can delete gmon.out.
Old 11-06-2005, 10:05 AM   #8
LQ Newbie
Registered: Nov 2005
Location: Bombay, India
Posts: 5

Rep: Reputation: 0
Use -rdynamic or -static option with the compiler.


I faced the same problem as posted by hemant and erwin. The solution is to use one of the following along with the -pg option:

* The -static option to gcc, if you are not using dynamic linking.
* If you are using dynamic linking, then use the -rdynamic option to gcc. This adds the global symbol table to the executable that is generated. I think this should have been on by default, when the -pg option is used.

So, try something like:

$ gcc -static -g -pg -Wall scan.c -o scan
$ gcc -rdynamic -g -pg -Wall scan.c -o scan

$ ./scan
$ gprof scan gmon.out

Hope this helps.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
gprof problem bogdanpa Programming 2 09-19-2005 08:26 AM
gprof newbie questions windmaomao Programming 2 08-04-2005 11:57 AM
gprof: gmon.out file is missing call-graph data hemk76 Programming 0 01-07-2005 11:54 PM
gprof error Sinner6 Linux - Software 0 07-12-2004 09:06 AM
Is there a gprof for C++? jhirshon Programming 2 04-29-2004 06:35 PM

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration