1.源文件 .cpp
2.预处理:将所有的#include头文件以及宏定义替换成其真正的内容(删除所有的注释、宏扩展、文件包含) .i
3.编译:转换为汇编语言 .s
4.汇编:转换为二进制机器码 .o(目标文件)
5.链接:链接过程将多个目标文件以及所需的库文件(.so等)链接成最终的可执行文件(executable file) .out
实际上运行代码

gcc -E hello.c -o test.i    获得.i文件  预处理
gcc -S hello.c -o test.s    获得.s文件  编译
gcc -c hello.c -o test.o    获得.o文件  汇编
ld -o test.out test.o inc/mymath.o ...libraries...    链接
gcc hello.c # 编译
./a.out # 执行

参考网址:C语言编译过程详解

posted on 2024-01-20 20:04  孜孜不倦fly  阅读(40)  评论(0)    收藏  举报