View Full Version : Profiling problems
Tindor
21st December 2006, 21:55
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 :(.
wysota
21st December 2006, 22:43
You should add the flag in your project file to the variable called QMAKE_CXXFLAGS_DEBUG.
Tindor
22nd December 2006, 15:55
Well, I added it, but it stil does not create gmon.out.
I also noticed this in the Makefile:
DEFINES = -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
And when I remove it and try "make" it's put in there again, maybe that's the problem.
jpn
22nd December 2006, 16:09
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
Tindor
23rd December 2006, 22:26
Well, now I can debug the program with gdb , but still no gmon.out is created :(
wysota
24th December 2006, 00:16
Does the compilation run with -pg compiler flags? Did you recreate the Makefile after modyfiing the project file?
Tindor
24th December 2006, 00:35
It does, here's the code:
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
Also, the makefile is supposed to be regenerated afer running qmake, am I wrong?
jacek
24th December 2006, 01:26
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:
#include <QApplication>
#include <QPushButton>
int main( int argc, char **argv )
{
QApplication app( argc, argv );
QPushButton b( "Close" );
QObject::connect( &b, SIGNAL( clicked() ), &b, SLOT( close() ) );
b.show();
return app.exec();
}
################################################## ####################
# 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.cpp
$ 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
Tindor
24th December 2006, 14:43
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 ! :)
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.