-pg 标志不产生 gmon.out 文件
-pg flags do not produce gmon.out file
我使用 -pg
标志编译和 link 我的 cpp 程序,运行 程序,并检查我的目录是否有 gmon.out
。我找不到任何东西。
我是 运行ning Ubuntu 16.04 LTS,这是一个完全默认的 codelite 项目。唯一的问题是我在 c++ 编译选项和 linking 选项中添加了 -pg
标志。
我已经阅读了所有其他询问相同问题的帖子。我相信我的问题有所不同。
这是我的 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/
这是项目中唯一的文件,main.cpp
:
#include <stdio.h>
int main(int argc, char **argv)
{
printf("hello world\n");
return 0;
}
编辑:
我将 main.cpp
更改为以下内容,现在可以使用了:
#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;
}
要么我至少需要一个非主要功能,要么gprof
不喜欢stdio.h
。任何人都可以尝试解释一下,如果他们愿意的话。
Gprof 是一个基于采样的探查器,您的第一个示例应用程序的执行量太小,无法被 Gprof 注册。
尝试在应用程序中添加一些 sleep(1)
调用,然后再试一次。
我使用 -pg
标志编译和 link 我的 cpp 程序,运行 程序,并检查我的目录是否有 gmon.out
。我找不到任何东西。
我是 运行ning Ubuntu 16.04 LTS,这是一个完全默认的 codelite 项目。唯一的问题是我在 c++ 编译选项和 linking 选项中添加了 -pg
标志。
我已经阅读了所有其他询问相同问题的帖子。我相信我的问题有所不同。
这是我的 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/
这是项目中唯一的文件,main.cpp
:
#include <stdio.h>
int main(int argc, char **argv)
{
printf("hello world\n");
return 0;
}
编辑:
我将 main.cpp
更改为以下内容,现在可以使用了:
#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;
}
要么我至少需要一个非主要功能,要么gprof
不喜欢stdio.h
。任何人都可以尝试解释一下,如果他们愿意的话。
Gprof 是一个基于采样的探查器,您的第一个示例应用程序的执行量太小,无法被 Gprof 注册。
尝试在应用程序中添加一些 sleep(1)
调用,然后再试一次。