-c 选项在 GCC 中的作用 [英] What does -c option do in GCC
问题描述
有谁知道 -c
标志在 gcc
中的作用吗?
比如有什么区别
gcc -c output0.cvs gcc output0.c
我知道第二个制作了 .a
文件,但我不知道 .a
文件是什么.
还有,-o
在
gcc output0.o -o output0
只是给输出文件命名对吗?
-c
编译或汇编源文件,但不要链接.链接阶段根本就没有完成.最终输出的形式是每个源文件的目标文件.
默认情况下,源文件的目标文件名由将后缀 .c、.i、.s 等替换为 .o.无法识别的输入不需要编译或组装的文件将被忽略.
<块引用>
-o 文件
将输出放在文件文件中.这适用于任何类型的正在生成输出,无论是可执行文件还是对象文件、汇编程序文件或预处理的 C 代码.如果 -o 不是指定,默认是在a.out中放一个可执行文件,source.o 中 source.suffix 的目标文件,其汇编文件位于source.s,source.suffix.gch 中的预编译头文件,以及所有标准输出上的预处理 C 源代码.
更多信息请参见 GCC 手册页
Does anyone know what does the -c
flag do in gcc
?
For example, what's the difference between
gcc -c output0.c
vs gcc output0.c
I know the second one makes a .a
file but I don't know what a .a
file is.
Also, what does -o
do in
gcc output0.o -o output0
Is it just to name the output file right?
-c
Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o. Unrecognized input files, not requiring compilation or assembly, are ignored.
-o file
Place output in file file. This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code. If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.
More can be found in GCC Manual Page
这篇关于-c 选项在 GCC 中的作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!