红联Linux门户
Linux帮助

gcc编译过程

发布时间:2006-11-05 00:54:25来源:红联作者:hfh08
gcc在编译c语言的实现
------简单语法
#gcc cu.c -o cu
#./cu
结果:hello world
其中:用gcc对源文件进行编译和连接,-o指定可执行文件的名称.
也可以这样:
#gcc cu.c
#./a.out
结果:hello world
上述过程看似简单但是gcc的工作远比这复杂,在执行过程中要:预处理、编译、汇编、连接、都是在gcc后台完成的。首先,gcc运行预处理程序cpp,展开成cu.c中的宏,并在其中插入#include文件所包含的内容,然后把预处理后的源代码变成目标代码,最后通过连接程序创建可执行文件。通常可用gcc中的-E选项。
为了使其显示更准确地执行过程如下命令:
#gcc -E cu.c -o cu.cpp
经过预处理后,gcc会把cu.cpp编译成目标代码。这个过程用gcc的-c选项实现。
#gcc -x cpp-output -c cu.cpp -o cu.c
使用gcc可以将多个文件源文件进行编译成目标文件。
#gcc prt.c printf2.c -o hello
#./hello
文章评论

共有 2187 条评论

  1. 203.168.112.* 于 2007-06-26 19:43:28发表:

    Hi boys! :
    music downloads = music download free = free music downloads = myspace music = free music = download music for free = free music for ipod = free mp3 files downloads = downloading song =
    http://www.freewebs.com/1fmusic/music-downloads.html free download music :: http://www.tonyshoes.com/albums/musicdownloads/?mp3music=12 music download free :: http://www.freewebs.com/1fmusic/limewire.html music downloads :: http://www.tonyshoes.com/albums/musicdownloads/?mp3music=95 myspace music :: http://idisk.mac.com/fmp3musicdownloads/Public/free-music.html free music :: http://idisk.mac.com/fmp3musicdownloads/Public/music.html free music :: http://www.freewebs.com/1fmusic/iPod-music.html free music for ipod :: http://idisk.mac.com/fmp3musicdownloads/Public/free-mp3-files-downloads.html free mp3 files downloads :: http://www.tonyshoes.com/albums/musicdownloads/?mp3music=84 downloading song :: http://idisk.mac.com/fmp3musicdownloads/Public/index.html free music :: http://www.tonyshoes.com/albums/musicdownloads/?mp3music=117 free music downloading programs ::
    mp3 downloads .. music download free .. music .. myspace music .. free music .. free music download .. free ipod music downloads ..