-c选项在GCC中做了什么? [英] What does -c option do in GCC

查看:160
本文介绍了-c选项在GCC中做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道 -c 标志在 gcc 中做了什么?



例如,

  gcc -c output0.c 
vs gcc之间有什么区别output0.c

我知道第二个使得 .a file,但我不是什么 .a 文件。



code> -o 在
$ b

 > gcc output0.o -o output0 

这只是为输出文件命名?

解决方案


-c
$ b


编译或汇编源文件,但不要链接。链接
阶段根本没有完成。最终的输出是每个源文件的
目标文件的形式。



默认情况下,源文件的目标文件名由
用.o替换后缀.c,.i,.s等。无法识别的输入
文件,不需要编译或汇编,将被忽略。


-o文件

将输出放入文件档案。这适用于任何类型的
输出,无论是可执行文件,
文件,汇编文件还是预处理C代码。如果指定-o不是
,则默认将a.out中的可执行文件放入source.o中的source.suffix的
目标文件中,将其汇编文件放入
源中。 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 what a .a file do.

Also what does the -o do in

gcc output0.o -o output0

It's 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆