文档详情

linux下一个小程序的编译过程详解(国外英文资料).doc

发布:2017-06-08约1.53万字共15页下载文档
文本预览下载声明
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
显示全部
相似文档