问候,
这是我的 SConstruct 文件:
env = Environment()
env.Append(CCFLAGS=['-g','-pg'])
env.Program(target='program1', source= ['program1.c'])
这也是编译的输出:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o program1.o -c -g -pg program1.c
gcc -o program1 program1.o
scons: done building targets.
正如您所看到的,我将“-pg”选项传递给构建环境。构建后,我运行程序来生成“gmon.out”,但它没有生成。
谁能确认这个问题吗?或者有解决办法吗?
Thanks.
Update:
感谢此处给出的建议,更新后的工作 SConstruct 文件如下。链接器需要该标志,因此要通过 scons 传递它,必须使用“LINKFLAGS”选项。
env = Environment()
env.Append(CCFLAGS=['-g','-pg'], LINKFLAGS=['-pg'])
env.Program(target='program1', source= ['program1.c'])
编译输出:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o program1.o -c -g -pg program1.c
gcc -o program1 -pg program1.o
scons: done building targets.
请注意链接阶段中的附加“-pg”。
链接器还需要-pg
在这种情况下的选项。来自 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.
尝试添加选项LDFLAGS
环境变量也是如此。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)