Chapter 29 . Programming Tools and Utilities 787 (Web server info)
Chapter 29 . Programming Tools and Utilities 787 Using the GCC Compiler The GNU Compiler Collection (GCC) is by far the most dominant compiler (rather, the most dominant collection of compilers) used on Linux systems. It compiles programs written in C, C++, Objective-C, Fortran, Java, and Ada. This chapter focuses on the C compiler. GCC gives programmers extensive control over the compilation process. That process includes up to four stages: preprocessing, compilation, assembly, and linking. You can stop the process after any of these stages to examine the compiler s output at that stage. GCC can also handle the various C dialects, such as ANSI C or traditional (Kernighan and Ritchie) C. You can control the amount and type of debugging information, if any, to embed in the resulting binary. And like most compilers, GCC also performs code optimization. The gcc command invokes the C compiler. To use it, provide it the name of a C source file and use its -o option to specify the name of the output file. gcc will preprocess, compile, assemble, and link the program, generating an executable, often called a binary. Here s the simplest syntax: gcc infile.c [-o outfile] infile.c is a C source code file and -o says to name the output file outfile. The [] characters indicate optional arguments throughout this book. If the name of the output file is not specified, gcc names the output file a.out by default. The following example uses gcc to create the hello program from the source file hello.c. First, the source code: /* * hello.c - canonical hello world program */ #include
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.