Prev | Current Page 1403 | Next

Christopher Negus

"Linux Bible, 2008 Edition: Boot up to Ubuntu, Fedora, KNOPPIX, Debian, openSUSE, and 11 Other Distributions"


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.
CROSS-REF
780
Programming in Linux Part VI
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.


Pages:
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415