gcc gives the programmers extensive control over the compilation process. The compilation process includes up to four stages:
Preprocessing(预处理)---------->Compilation Proper(彻底编译)-------->Assembly(汇编)--------->Linking(链接)
gcc编译的一些主要参数:
eg. gcc hello.c -o hello
1 、gcc -E hello.c -o hello.cpp -E 预处理,即将头文件包含进来。
2、 gcc -x cpp-output -c hello.cpp -o hello.o
-x 编译预处理之后的文件,生成目标文件(.o)。
3、 -g 生成用于gdb调试的调试信息。
4、 -ansi Support the ANSI/ISO C standard, turning off GNU extensions that conflict with the standard(this option does not tuarantee ANSI-compliant code).
5、 -pedantic Emit all warnings required by the ANSI/ISO C standard.
6 、 -pedantic-errors Emit all errors required by the ANSI/ISO C standard.
Library and Include File:
如果有库或者头文件没有在标准的包含路径内, -L{DIRNAME} and -I{DIRNAME} option allow you to specify these locations and to insure that they are searched before the standard locations.
假如你有包含文件在路径/usr/local/include/killerapp目录下,要使gcc包含它,可以用如下命令:
eg. $gcc someapp.c -I/usr/local/include/killerapp
包含库(.lib)
$gcc myapp.c -L/home/fred/lib -I/home/fred/include -lnew
初学,一些讲的比较详细但不是基本应用的没有去深入研习,以后用到的时候回来翻看。