您的位置:首页 > 其它

gcc编译过程

2012-11-03 09:55 309 查看
[hayuk@localhost qinghua]$ touch hello.c
[hayuk@localhost qinghua]$ ls
hello.c
[hayuk@localhost qinghua]$ vim hello.c

// liangxiaxu@126.com

#include <stdio.h>

int main(void)
{
printf("hello, gcc!\n");
return 0;
}
// vim: set tabstop=4 shiftwidth=4 expandtab:


[hayuk@localhost qinghua]$ ls

hello.c

// 预处理 替换宏

[hayuk@localhost qinghua]$ gcc -E hello.c -o hello.i

[hayuk@localhost qinghua]$ ls

hello.c hello.i

// 编译 检查语法

[hayuk@localhost qinghua]$ gcc -S hello.i -o hello.s

[hayuk@localhost qinghua]$ ls

hello.c hello.i hello.s

// 汇编 生成机器语言

[hayuk@localhost qinghua]$ gcc -c hello.s -o hello.o

[hayuk@localhost qinghua]$ ls

hello.c hello.i hello.o hello.s

// 链接 链接.o文件或和外部链接库,生成可执行文件

[hayuk@localhost qinghua]$ gcc hello.o -o hello

[hayuk@localhost qinghua]$ ls

hello hello.c hello.i hello.o hello.s

// 执行

[hayuk@localhost qinghua]$ ./hello

hello, gcc!

[hayuk@localhost qinghua]$ ls

hello hello.c hello.i hello.o hello.s
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: