views:

367

answers:

5

Well I've the following problem.

Facts; - Using eclipse - Using MinGW

I wanted to benchmark my created C++ program. I searched google and then came; http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html

I then wanted to add the "-pg" build command. But how/where do I add it? I went in to the "properties - C/C++ build - Discovery Options" and added it to the "Compiler invocation command" (http://img515.imageshack.us/img515/3159/67826349.png) but it did nothing, as far as I can see in the console.

So what am I doing wrong?

+1  A: 

Move the "-pg" from the "compiler invocation command", into the "Compiler invocation arguments"

Kelly French
A: 

Well I tried that also. But when I add it the console doesn't say anything that it has been applied.

**** Internal Builder is used for build ****
g++ -O3 -Wall -c -fmessage-length=0 -omain.o ..\main.cpp
g++ -oPE-Problem1.exe main.o

And even it is applied I'm still not getting the "gmon.out" file that should be created after I run the application once.

ReWout
A: 

Note that you need to use -pg also while linking.

Amit Kumar
A: 

under proprieties of the your project go to settings under c/c++ build hen on the right hand of the settings box go to tool settings under gcc c++ compiler you find debbuging there you find the option to generate gprof information

Yassine
+1  A: 

If it is a Makefile based project, make sure you add -pg to the CXXFLAGS variable in the Makefile. This will ensure that everything needed for profiling (more than the usual debug symbols) is built into the object files. You also will need to add -pg to the line where the executable is created. Chances are that it will look like the following:

$(CXX) -o $(TARGET) $(OBJS) $(LIBS)

You will want to add in the -pg there. That will make sure that the profiling information is also built into the executable. Now a gmon.out file should be produced when you run the program. It will only be produced if the program exits normally though.

vorporeal