Hi all,
This might be bit of a silly question, but it's stumped me now for over a day and I've scourged the net for info but haven't found anything to sort out what I should be doing.
I am currently using Qt Creator 1.3.1 (Based on Qt 4.6.2 (32 bit)) to develop my code. I have a fully functioning program that I would now like to profile.
After searching the net I discovered that gprof is quite handy in providing a table indicating the runtime taken for various parts of the program.
My understanding is that in order to use gprof, I have to generate a gmon.out file, and that in turn this is generated by compiling and running my program with the "-pg" option.
So I discovered that I have to add a number of flags to my project file in Qt Creator to enable this option. My project file looks as follows:
SOURCES += accretion.cpp \
environment.cpp \
particle.cpp \
random.cpp \
simulation.cpp
HEADERS += environment.h \
particle.h \
random.h \
simulation.h \
ran.h
OTHER_FILES += tempfile.txtCONFIG(release, debug|release):
QMAKE_CFLAGS+=-pg
QMAKE_CXXFLAGS+=-pg
QMAKE_LFLAGS+=-pg
I then compile and run the program, but no gmon.out file is generated as far as I can see.
I've tried looking up other flag info and it seems that the flags I'm using should work.
The start of the Makefile generated is as follows:
#############################################################################
# Makefile for building: MSPS.app/Contents/MacOS/MSPS
# Generated by qmake (2.01a) (Qt 4.6.2) on: Tue Mar 23 10:28:50 2010
# Project: MSPS.pro
# Template: app
# Command: /usr/bin/qmake -spec /usr/local/Qt4.6/mkspecs/macx-g++ -macx -o Makefile MSPS.pro
#################################################################################### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -pg -g -gdwarf-2 -arch i386 -Wall -W $(DEFINES)
CXXFLAGS = -pipe -pg -g -gdwarf-2 -arch i386 -Wall -W $(DEFINES)
INCPATH = -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I. -F/Library/Frameworks
LINK = g++
LFLAGS = -headerpad_max_install_names -pg -arch i386
LIBS = $(SUBLIBS) -F/Library/Frameworks -L/Library/Frameworks -framework QtGui -framework QtCore
AR = ar cq
RANLIB = ranlib -s
QMAKE = /usr/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = cp -f
COPY_DIR = cp -f -R
STRIP =
INSTALL_FILE = $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = $(COPY_FILE)
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
export MACOSX_DEPLOYMENT_TARGET = 10.4
It seems to me that the "-pg" option is correctly added to the necessary flags.
If anyone can help me sort out why there is no gmon.out file generated, I would be very grateful.
Thanks in advance,
Kartik