使用gcc编译一个应用程序需要经过预处理(preprocessing)、编译(compilation)、汇编(assembly)和链接(linking)4个步骤才能生成可执行文件。
src
int main(int argc, char *argv[])
{
printf("Hello, world\n");
return 0;
}
preprocessing
gcc -E -o hello.i hello.c
compilation
gcc -S -o hello.S hello.i
assembly
gcc -c -o hello.o hello.S
linking
gcc -o hello hello.o
最后执行可执行文件
./hello