Hi,
I've just written my small app, but want to profile it in order to optimize it.
I tried adding -pg flags in the CFLAGS, CXXFLAGS, LIBS and in the make targets, but no gmon.out is created. I googled the problem, but found no answer.
Hi,
I've just written my small app, but want to profile it in order to optimize it.
I tried adding -pg flags in the CFLAGS, CXXFLAGS, LIBS and in the make targets, but no gmon.out is created. I googled the problem, but found no answer.
You should add the flag in your project file to the variable called QMAKE_CXXFLAGS_DEBUG.
Tindor (24th December 2006)
Well, I added it, but it stil does not create gmon.out.
I also noticed this in the Makefile:
And when I remove it and try "make" it's put in there again, maybe that's the problem.Qt Code:
DEFINES = -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHAREDTo copy to clipboard, switch view to plain text mode
Looks like you are compiling a release version. Also, you must compile and link it with the corresponding profiling flags.
QMAKE_CXXFLAGS_DEBUG *= -pg
QMAKE_LFLAGS_DEBUG *= -pg$ qmake -config debug
$ make
J-P Nurmi
Tindor (24th December 2006), vfernandez (3rd January 2007)
Well, now I can debug the program with gdb , but still no gmon.out is created![]()
Does the compilation run with -pg compiler flags? Did you recreate the Makefile after modyfiing the project file?
Tindor (24th December 2006)
It does, here's the code:
Also, the makefile is supposed to be regenerated afer running qmake, am I wrong?g++ -c -pipe -g -pg -pg -Wall -W -D_REENTRANT -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I. -I/usr/include -I. -I. -o main.o main.cpp
Last edited by jacek; 24th December 2006 at 00:11. Reason: changed [code] to [quote]
How do you start that application? gmon.out will be generated in the current directory and only if your application exits cleanly.
Check if you can generate gmon.out for this small example:
Qt Code:
#include <QApplication> #include <QPushButton> int main( int argc, char **argv ) { b.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
Qt Code:
###################################################################### # Automatically generated by qmake (2.00a) nie gru 24 01:16:45 2006 ###################################################################### TEMPLATE = app TARGET += DEPENDPATH += . INCLUDEPATH += . CONFIG += debug QMAKE_CXXFLAGS_DEBUG *= -pg QMAKE_LFLAGS_DEBUG *= -pg # Input SOURCES += main.cppTo copy to clipboard, switch view to plain text mode
$ ls
main.cpp prof.pro
$ qmake
$ make
...
$ ls
main.cpp main.o Makefile prof prof.pro
$ ./prof
$ ls
gmon.out main.cpp main.o Makefile prof prof.pro
Oops, I'm sorry I made you write the code. I've forgotten that I had to run the app in order to get a gmon.out.
Thank you very much !![]()
I am having a similar issue. My program is a very large program and I created my own shared libraries, but when I try to compile them with the -pg flag set in QMAKE_CXXFLAGS_DEBUG and in QMAKE_LFLAGS_DEBUG and then run it I don't get the gmon.out.
It is exiting normally and I have it set so that all the shared libraries are building with the flags. Any ideas?
This is a known issue with gprof. Please google around for using gprof with shared object files or use a different profiler such as Valgrind's callgrind tool.
gprof is the reason I don't get the gmon.out file? I thought that was part of the gcc
It's part of gcc but it's made for gprof. You'll find solutions much quicker if you google for "gprof and shared object files" than for "gcc and shared object files". And the file should be generated. It might be meaningless but it should get generated. Are you sure you linked with the -pg flag as well?
Yes it is in the linker string as well...I am trying to get it to work with shared libraries, but I can't get it to work with just a single executable either.
Check the actual compilation line (not what's inside qmake project file) if -pg is there for both compiling and linking phase. Also be sure to compile with -g (debug).
I think I found the issue, I just don't know how to fix it. gcc -pg main.c works fine but g++ -pg main.cpp compiles but doesn't output a gmon.out file. For some reason a C file will give us a profile but a C++ file wont.
Since this no longer seems to be a Qt issue I have posted the question in the google groups gnu.g++.help section. Thanks for the help
It must not be that simple. It works just fine for me. Try Jacek's example.
J-P Nurmi
I tried his example...word for word and it doesn't produce a gmon.out file. the last line of the make output says....
Warning: consider linking with '-static' as system libraries with profiling support are only provided in archive format.
Currently Qt is built dynamically because the project I am on can't be built statically.
Bookmarks