Discussion:
cannot profile a c++ program
(too old to reply)
Wiseguy
2005-04-03 01:34:26 UTC
Permalink
I compile a short c++ program using

c++ -Iwhatever myprogram.cpp -o myprogram -g -pg

the program runs (slowly based on the profiling information being
included), but it doesn't create a gmon.out file as it is suppose to
do.

I use return 0; to exit from the main function. I'm using gcc 3.3

anyone aware of problems in linux with profiling?


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Stefano Chiappa
2005-06-20 08:27:54 UTC
Permalink
Hi,
I had a similar problem, pehaps even in your case the problem is due to
the linker, infact the -pg option has to be used also for the linking:

c++ myprogram.o -pg

You're right for the exit() function. If the program terminates without
calling return from main or without using exit() you don't get the
profiling info. Another thig: while the profile is statistic, you could
get surprisely result if the program spends a lot of time while waiting
for I/O stuffs . . . is best to launch the program an let him to work a
lot to get interesting results...
Stefano
Post by Wiseguy
I compile a short c++ program using
c++ -Iwhatever myprogram.cpp -o myprogram -g -pg
the program runs (slowly based on the profiling information being
included), but it doesn't create a gmon.out file as it is suppose to
do.
I use return 0; to exit from the main function. I'm using gcc 3.3
anyone aware of problems in linux with profiling?
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Loading...