GCC 编译选项语法
我正在尝试 gprof 我的程序。我想要逐行分析。 但是,我似乎无法正确理解语法。我使用的是“make”而不是“gcc”,所以请只提供适合 make 的建议。如果您能给我完整的“make”语法,我将非常感激。 基于该网站: http://sourceware.org/binutils/docs/gprof/Output-Options.html [^] http://sourceware.org/binutils/docs/gprof/Line_002dby_002dline.html [^] 这是我输入的内容:
make USE_LOCAL_HEADERS=0 LDFLAGS='-L.' BASE_CFLAGS=-m32 CFLAGS='-fopenmp -pg -l -g'
输出是:
/usr/bin/ld: cannot find -l-g
collect2: ld returned 1 exit status
make[2]: *** [build/release-linux-ppc64/ioquake3.ppc64] Error 1
make[2]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/svfb_201110271440/ioquake3dev_clean'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/svfb_201110271440/ioquake3dev_clean'
make: *** [release] Error 2
我需要选项“-l”、“-g”和“-pg”。
I am trying to gprof my program. I want a line-by-line profiling.
However, I can't seem to get the syntax right. I am using "make" and not "gcc" so please help only with suggestions that fit make. I wouldbe very grateful if you can give me the full "make" syntax.
Based on this website:
http://sourceware.org/binutils/docs/gprof/Output-Options.html[^]
http://sourceware.org/binutils/docs/gprof/Line_002dby_002dline.html[^]
Here is what I am inputting:
make USE_LOCAL_HEADERS=0 LDFLAGS='-L.' BASE_CFLAGS=-m32 CFLAGS='-fopenmp -pg -l -g'
The output is:
/usr/bin/ld: cannot find -l-g
collect2: ld returned 1 exit status
make[2]: *** [build/release-linux-ppc64/ioquake3.ppc64] Error 1
make[2]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/svfb_201110271440/ioquake3dev_clean'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/svfb_201110271440/ioquake3dev_clean'
make: *** [release] Error 2
I need option "-l", "-g" and "-pg".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
-pg
启用分析,-g
包含有助于解释生成的配置文件的符号名称。-pg
选项需要传递给编译器和链接器。-l
命令在您使用它的方式中没有意义,因为它需要一个库名称作为参数,因此只要您不提供库名称,就保留-l< /code> 离开。
另外,在开发过程中,我建议使用
-Wall
选项来启用编译期间的所有警告。所以你可以尝试这个 make 命令:
-pg
enables profiling,-g
includes symbol names which help interpreting the profile generated.The
-pg
option needs to be passed to compiler and linker.The
-l
command does not make sense in the way you are using it, as it needs a library name as parameter, so as long as you do not provide one, leave the-l
away.Also during development I'd recommend the
-Wall
option to enable all warnings during compilation.So you might try this make command:
您可以将其中大部分作为环境变量传递,让“应该”做正确的事情并将它们用于编译器:
这将 USE_LOCAL_HEADERS、LDFLAGS、BASE_CFLAGS 和 CFLAGS 作为 make 和 gcc 可以看到的环境变量。您可能需要编辑 Makefile 以按照您想要的正确方式组合它们。
You can pass most of those as environment variables, make "should" do the right thing and use them for the compiler:
That will USE_LOCAL_HEADERS, LDFLAGS, BASE_CFLAGS and CFLAGS as environment variables which make and gcc can see. You may have to edit your Makefile to combine them in the correct ways for what you want.
make
只是“自动确定大型程序的哪些部分需要重新编译,并发出重新编译它们的命令”(man make)。看起来make
无法理解你的论点;在遇到错误之前它实际上不会运行任何命令。很抱歉,我无法进一步帮助您,但您的问题出在您的 make 文件或类似文件中。您应该阅读什么是 make 文件,以及如何 gprof 您的程序并了解 make 和 gcc 之间的区别,并重新评估您正在尝试执行的操作。 make 可能对你没用。
make
is simply a "to determine automatically which pieces of a large program need to be recompiled, and issue the commands to recompile them" (man make). It looks likemake
cannot make sense of your arguments; it doesn't actually get to run any commands before it encounters an error.I'm sorry I can't help you any further, but your problem is within your make file or similar. You should read up on what a make file is, and how to gprof your program and understand the difference between make and gcc, and reevaluate what you are trying to do. Make may not be useuful to you.