gcc常用命令
常用选项
一个c文件要经过如下处理才能变成可执行文件
Step1:预编译 gcc -E -o hello.i hello.c
Step2:编译 gcc -S -o hello.s hello.i
Step3:汇编 gcc -c -o hello.o hello.s
Step4:链接 gcc -o hello hello.o
如果要一步到位
gcc -o hello hello.c
下面看下每一步生成的文件长什么样
Step1:预编译 gcc -E -o hello.i hello.c
可以看到最后把宏展开,头文件加入等
Step2:编译 gcc -S -o hello.s hello.i
可以看到编程了汇编语言
Step3:汇编 gcc -c -o hello.o hello.s
变成了而二进制文件
Step4:链接 gcc -o hello hello.o
最后的文件就是再该平台上的可执行文件(我这里取名了个sh后缀)
一步到位的话