最近想用gprof优化一下程序,奇怪的是怎么也不产生gmon.out文件,在网上查了一些方法,也没有解决,然后在 man gcc中看到一句话:
-pg Generate extra code to write profile information suitable for the
analysis program gprof. You must use this option when compiling
the source files you want data about, and you must also use it when
linking.
要想产生gmon.out文件,必须在编译和链接时,都加上-pg -g选项。
如果还是没有解决:可以参考一下下面网址:
http://blog.csdn.net/crazyhacking/article/details/11972889