An Introduction to GCC


An Introduction to GCC provides an introduction to the GNU C and C++ Compilers, gcc and g++, which are part of the GNU Compiler Collection (GCC).

This book explains how to use the compiler itself. Based on years of observation of questions posted on mailing lists, it guides the reader straight to the important options of GCC.

This book is a guide to getting started with GCC, the GNU Compiler Collection. It will tell you how to use GCC as a programming tool. GCC is a programming tool, that’s true–but it is also something more. It is part of a 20-year campaign for freedom for computer users. We all want good software, but what does it mean for software to be “good”? Convenient features and reliability are what it means to be technically good, but that is not enough. Good software must also be ethically good: it has to respect the users’ freedom.

  • Compiling a C program – describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header files
  • Compilation options – describes other commonly-used compiler options available in GCC. These options control features such as the search paths used for locating libraries and include files, the use of additional warnings and diagnostics, preprocessor macros and C language dialects
  • Using the preprocessor – describes the use of the GNU C preprocessor cpp, which is part of the GCC package. The preprocessor expands macros in source files before they are compiled. It is automatically called whenever GCC processes a C or C++ program
  • Compiling for debugging – provides the -g debug option to store additional debugging information in object files and executables. This debugging information allows errors to be traced back from a specific machine instruction to the corresponding line in the original source file
  • Compiling with optimization – GCC is an optimizing compiler. It provides a wide range of options which aim to increase the speed, or reduce the size, of the executable files it generates
  • Compiling a C++ program – describes how to use GCC to compile programs written in C++, and the command-line options specific to that language
  • Platform-specific options – describes some of the options available for common platforms: Intel and AMD x86 options, x86 extensions, x86 64-bit processors, DEC Alpha options, SPARC options, POWER/PowerPC options, Multi-architecture support, and floating-point issues
  • Troubleshooting – GCC provides several help and diagnostic options to help troubleshoot problems with the compilation process
  • Compiler-related tools – describes a number of tools which are useful in combination with GCC. These include the GNU archiver ar, for creating libraries, and the GNU profiling and coverage testing programs, gprof and gcov
  • How the compiler works – describes in more detail how GCC transforms source files to an executable file. Compilation is a multi-stage process involving several tools, including the GNU Compiler itself (through the gcc or g++ frontends), the GNU Assembler as, and the GNU Linker ld. The complete set of tools used in the compilation process is referred to as a toolchain
  • Examining compiled files – describes several useful tools for examining the contents of executable files and object files
  • Common error messages – describes the most frequent error and warning messages produced by gcc and g++. Each case is accompanied by a description of the causes, an example and suggestions of possible solutions
  • Getting help – if readers encounters a problem not covered by this introduction, there are several reference manuals which describe GCC and language-related topics in more detail



Total pages:144
Author:Brian Gough


  1. Foreword by Richard M. Stallman
  2. Introduction
  3. Compiling a C program
  4. Compilation options
  5. Using the preprocessor
  6. Compiling for debugging
  7. Compiling with optimization
  8. Compiling a C++ program
  9. Platform-specific options
  10. Troubleshooting
  11. Compiler-related tools
  12. How the compiler works
  13. Examining compiled files
  14. Common error messages
  15. Getting help
  16. Further Reading
  17. Acknowledgements
  18. Concept Index


Read/ Download

onlineDownload PDF


This book is published under the GNU Free Documentation License.

Leave a Reply

Your email address will not be published. Required fields are marked *