- 1、本文档共15页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
linux下一个小程序的编译过程详解(国外英文资料)
linux下一个小程序的编译过程详解(国外英文资料)
To read this article, you need to have a basic understanding of C, and this article will show you how to use the GCC compiler. First, well show you how to compile a simple C source code using the compiler in command-line mode. Then, we briefly describe what the compiler is doing and how to control the compilation process. We also briefly introduced the use of the debugger.
GCC rules
Can you imagine compiling free software with a private compiler that USES closed source code? How do you know what the compiler adds to your executable? There may be backdoors and trojans. Ken Thompson is a well-known hacker who writes a compiler that leaves a backdoor and a permanent Trojan in the login program when the compiler compiles itself. Please read his description of the masterpiece here. Fortunately, we have GCC. When you do configure; Make; When make install, GCC did a lot of heavy work behind the scenes. How do you get GCC to work for us? Were going to start writing a card game, but were just trying to demonstrate the compilers functionality, so were trying to simplify the code as much as possible. Well start from scratch to understand the compilation process and understand what needs to be done to make executable files, and in what order. Well look at how to compile the C program and how to use the compiler options to make GCC work as we ask. The steps (and the tools used) are as follows: precompiled (GCC - E), compiled (GCC), assembly (as), and connection (ld).
Began to...
First, we should know how to invoke the compiler. In fact, its easy. Were going to start with that famous first C program. Please forgive me, old timers.
# include stdio, h
Int main ()
{
Printf ( Hello World! \ n );
}
Save the file as game. C. You can compile it at the command line:
GCC game. C
By default, the C compiler generates an executable file named a.ut. You can type the following command to run it:
a.out
Hello World
Each time the compiler is compiled, the new a.out wi
文档评论(0)