C++ -pg标志不生成gmon.out文件

C++ -pg标志不生成gmon.out文件,c++,gprof,codelite,C++,Gprof,Codelite,我用-pg标志编译并链接我的cpp程序,运行该程序,并检查目录中的gmon.out。我什么也找不到 我正在运行Ubuntu16.04LTS,这是一个完全默认的codelite项目。唯一的事情是,我将 -PG< /Cult>标志添加到C++编译选项和链接选项中。p> 我已经阅读了所有其他关于同一问题的帖子。我相信我的问题是不同的 这是我的makefile: ## ## Auto Generated makefile by CodeLite IDE ## any manual changes wil

我用
-pg
标志编译并链接我的cpp程序,运行该程序,并检查目录中的
gmon.out
。我什么也找不到

我正在运行Ubuntu16.04LTS,这是一个完全默认的codelite项目。唯一的事情是,我将<代码> -PG< /Cult>标志添加到C++编译选项和链接选项中。p> 我已经阅读了所有其他关于同一问题的帖子。我相信我的问题是不同的

这是我的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; 
}

我需要至少一个非主函数,或者
gprof
不喜欢
stdio.h
。任何人都可以尝试解释一下,如果他们愿意的话。

Gprof是一个基于采样的探查器。您的第一个示例应用程序执行太小,无法由Gprof注册


尝试在应用程序中添加一些
sleep(1)
调用,然后重试。

Gprof是一个基于采样的探查器。您的第一个示例应用程序执行太小,无法由Gprof注册

尝试在应用程序中添加一些
sleep(1)
调用,然后重试

#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;
}