编译和链接

来源:互联网 发布:jstor数据库怎么用 编辑:程序博客网 时间:2024/06/04 01:13

1.用gcc编译、运行c语言的一个helloworld程序,事实上,上述过程可以分解为4个步骤,分别是预处理(Prepressing)、编译(Compilation)、汇编(Assembly)和链接(Linking),如下图所所示:


2.gcc 命令的一些参数用法介绍

 -c   compile or assemble the source files, but do not link. replacing the suffic .c, .i, .s,  with .o


  -S stop after the comilation proper; do not assemble.    replacing the suffic .c, .i, with .s


   -E stop after the prepressing stage; do not compiler proper.

  预编译过程主要处理那些源代码文件以“#”开始的预编译指令。比如“#include”、“define”等,删除所有的注释语句

 编译:将预处理完的文件进行一系列词法分析、语法分析、语义分析及优化目标代码