- 显示当前目录的文件用
ls
,如果要显示详细信息用ls -l
- 新建一个c语言文件命名为
hello.c
#include <stdio.h>
int main()
{
printf("hello world.\n");
return 0;
}
直接使用命令gcc hello.c
会生成一个hello.out
的文件,只想./a.out
就会显示结果
要想生成自己想要的文件名,
使用gcc hello.c -o hello
或者gcc -o hello hello.c
- 编译过程
预处理阶段(Pre-Processing)
gcc -E hello.c -o hello.i
编译阶段
gcc -S hello.i -o hello.s
汇编阶段
gcc -c hello.s -o hello.o
链接
gcc hello.o -o hello