gpreftool使用

1. 下载源码:https://github.com/gperftools

2. 解压,编译

3. 进入解压文件夹

4. ./autogen.sh

这个位置报错

./autogen.sh: 3: autoreconf: not found

原因,需要安装autoconf

sudo apt install autoconf

再次执行,还是报错

configure.ac:179: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.

原因:

        sudo apt-get install libtool

再次执行OK

5. ./configure

6. make -j8

7. 编译代码

g++ main.cpp -Wl,--no-as-needed,-lprofiler,--as-needed -o demo

注意,如只添加-lprofile,运行的时候生成不了报告,还不知道为什么

8. env CPUPROFILE=res.prof CPUPROFILESIGNAL=12 ./demo

自己配置了 一个信号,方便控制输出

        

你可能感兴趣的:(C++,项目问题整理,linux)