看这个stage图不错所以就引用过来了.
原文是Anjuta的build教程。
原文地址:
$gcc -g -Wall -I/usr/include/libxml2/libxml -lxml2 main.c aux.c -o tut_prog |
如果对编译过程进行分解的话,可以参考gcc的手册,加入-c -S -E 的一些options就能够留存住,过程中生成的文件
例如:*.o *.s 文件
*.i文件是被发送到标准输出端的,在shell窗口中可以看到。
下记内容引致gcc的man手册。
----------------------------
。。。。。。。
If you only want some of the stages of compilation, you can use
-x (or filename suffixes) to tell gcc where to start, and
one of the options -c, -S, or -E to say where
gcc is to stop. Note that some combinations (for example,
-x cpp-output -E) instruct gcc to do nothing at all.
- -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.
- -S
-
Stop after the stage of compilation proper; do not assemble. The output
is in the form of an assembler code file for each non-assembler input
file specified.
By default, the assembler file name for a source file is made by
replacing the suffix .c, .i, etc., with .s.
Input files that don't require compilation are ignored.
- -E
-
Stop after the preprocessing stage; do not run the compiler proper. The
output is in the form of preprocessed source code, which is sent to the
standard output.
Input files which don't require preprocessing 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 you specify -o when compiling more than one input file, or
you are producing an executable file as output, all the source files
on the command line will be compiled at once.
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, and
all preprocessed C source on standard output.
- -v
-
Print (on standard error output) the commands executed to run the stages
of compilation. Also print the version number of the compiler driver
program and of the preprocessor and the compiler proper.
。。。。。
$ gcc -E main.c >& main.i
*.i文件向标准输入输出终端输出,所以上记写法,可生成main.i的文本文件进行查看。
$ gcc -S main.c
生成main.s 汇编文件(汇编语句)
$ gcc -c main.c
生成main.o的二进制文件
$ gcc -o main main.c
生成名为main的可执行二进制文件
阅读(1488) | 评论(0) | 转发(0) |