I compile and link my cpp program with the -pg
flag, run the program, and check my directory for gmon.out
. I can't find anything.
I am running Ubuntu 16.04 LTS, and this is a completely default codelite project. The only thing is I added the -pg
flag to the c++ compiling options and the linking options.
I have read all of the other threads asking about the same problem. I believe my issue is different.
Here is my makefile:
##
## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased
##
## Release
ProjectName :=trying_reproducible_gprof_error
ConfigurationName :=Release
WorkspacePath :=/home/taylor/Documents/ssmworkspace
ProjectPath :=/home/taylor/Documents/ssmworkspace/trying_reproducible_gprof_error
IntermediateDirectory :=./Release
OutDir := $(IntermediateDirectory)
CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=taylor
Date :=20/02/17
CodeLitePath :=/home/taylor/.codelite
LinkerName :=/usr/bin/g++
SharedObjectLinkerName :=/usr/bin/g++ -shared -fPIC
ObjectSuffix :=.o
DependSuffix :=.o.d
PreprocessSuffix :=.i
DebugSwitch :=-g
IncludeSwitch :=-I
LibrarySwitch :=-l
OutputSwitch :=-o
LibraryPathSwitch :=-L
PreprocessorSwitch :=-D
SourceSwitch :=-c
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
Preprocessors :=$(PreprocessorSwitch)NDEBUG
ObjectSwitch :=-o
ArchiveOutputSwitch :=
PreprocessOnlySwitch :=-E
ObjectsFileList :="trying_reproducible_gprof_error.txt"
PCHCompileFlags :=
MakeDirCommand :=mkdir -p
LinkOptions := -pg
IncludePath := $(IncludeSwitch). $(IncludeSwitch).
IncludePCH :=
RcIncludePath :=
Libs :=
ArLibs :=
LibPath := $(LibraryPathSwitch).
##
## Common variables
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
##
AR := /usr/bin/ar rcu
CXX := /usr/bin/g++
CC := /usr/bin/gcc
CXXFLAGS := -pg -O2 -Wall $(Preprocessors)
CFLAGS := -O2 -Wall $(Preprocessors)
ASFLAGS :=
AS := /usr/bin/as
##
## User defined environment variables
##
CodeLiteDir:=/usr/share/codelite
Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix)
Objects=$(Objects0)
##
## Main Build Targets
##
.PHONY: all clean PreBuild PrePreBuild PostBuild MakeIntermediateDirs
all: $(OutputFile)
$(OutputFile): $(IntermediateDirectory)/.d $(Objects)
@$(MakeDirCommand) $(@D)
@echo "" > $(IntermediateDirectory)/.d
@echo $(Objects0) > $(ObjectsFileList)
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
MakeIntermediateDirs:
@test -d ./Release || $(MakeDirCommand) ./Release
$(IntermediateDirectory)/.d:
@test -d ./Release || $(MakeDirCommand) ./Release
PreBuild:
##
## Objects
##
$(IntermediateDirectory)/main.cpp$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/taylor/Documents/ssmworkspace/trying_reproducible_gprof_error/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/main.cpp$(DependSuffix): main.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/main.cpp$(DependSuffix) -MM main.cpp
$(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main.cpp$(PreprocessSuffix) main.cpp
-include $(IntermediateDirectory)/*$(DependSuffix)
##
## Clean
##
clean:
$(RM) -r ./Release/
Here's the only file in the project, main.cpp
:
#include <stdio.h>
int main(int argc, char **argv)
{
printf("hello world\n");
return 0;
}
Edit:
I changed main.cpp
to the following, and now it works:
#include <iostream>
void printLol(){
std::cout << "lol........\n";
}
int main(int argc, char **argv)
{
std::cout << "hello world\n";
for(int i = 0; i < 10; ++i)
printLol();
return 0;
}
Either I need at least one non-main function, or gprof
doesn't like stdio.h
. Anybody can take a stab at explaining that if they want.