0.3 c 语言编译过程
来自: https://www.cnblogs.com/CarpenterLee/p/5994681.html

预处理 preprocessor gcc- E 是把 .c 源代码处理成 .i
编译 compilation gcc -S 处理成 .s 特定的汇编代码
汇编 assemble gcc -c 把 .s 文件处理 .o
.o 是一个二进制文件
.out 是一个可执行文件
从 .o 到 .out 的过程就是一个链接 linking
2023-08-31
//
// main.c
// kr-c
//
// Created by labspc on 2023/8/23.
//
#include <stdio.h>
int main(int argc, const char * argv[]) {
// insert code here...
printf("Hello, World!\n");
return 0;
}
// Some code
gcc -E main.c -o main.i
gcc -S main.c -o main.s
gcc main.o -o main.out 直接链接 .o文件>>.out
gcc -c main.s -o main.o 汇编的过程
gcc main.o -o main.out 链接
// Some code
gcc main.c
./a.out
a.out 和 main.out 是一样的。
Last updated
Was this helpful?