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.
1 Introduction
1.1 A brief history of GCC
1.2 Major features of GCC
1.3 Programming in C and C++
1.4 Conventions used in this manual
2 Compiling a C program
2.1 Compiling a simple C program
2.2 Finding errors in a simple program
2.3 Compiling multiple source files
2.4 Compiling files independently
2.4.1 Creating object files from source files
2.4.2 Creating executables from object files
2.4.3 Link order of object files
2.5 Recompiling and relinking
2.6 Linking with external libraries
2.6.1 Link order of libraries
2.7 Using library header files
3 Compilation options
3.1 Setting search paths
3.1.1 Search path example
3.1.2 Environment variables
3.1.3 Extended search paths
3.2 Shared libraries and static libraries
3.3 C language standards
3.3.1 ANSI/ISO
3.3.2 Strict ANSI/ISO
3.3.3 Selecting specific standards
3.4 Warning options in -Wall
3.5 Additional warning options
4 Using the preprocessor
4.1 Defining macros
4.2 Macros with values
4.3 Preprocessing source files
5 Compiling for debugging
5.1 Examining core files
5.2 Displaying a backtrace
6 Compiling with optimization
6.1 Source-level optimization
6.1.1 Common subexpression elimination
6.1.2 Function inlining
6.2 Speed-space tradeoffs
6.2.1 Loop unrolling
6.3 Scheduling
6.4 Optimization levels
6.5 Examples
6.6 Optimization and debugging
6.7 Optimization and compiler warnings
7 Compiling a C++ program
7.1 Compiling a simple C++ program
7.2 Using the C++ standard library
7.3 Templates
7.3.1 Using C++ standard library templates
7.3.2 Providing your own templates
7.3.3 Explicit template instantiation
7.3.4 The export keyword
8 Platform-specific options
8.1 Intel and AMD x86 options
8.2 DEC Alpha options
8.3 SPARC options
8.4 POWER/PowerPC options
8.5 Multi-architecture support
9 Troubleshooting
9.1 Help for command-line options
9.2 Version numbers
9.3 Verbose compilation
10 Compiler-related tools
10.1 Creating a library with the GNU archiver
10.2 Using the profiler gprof
10.3 Coverage testing with gcov
11 How the compiler works
11.1 An overview of the compilation process
11.2 The preprocessor
11.3 The compiler
11.4 The assembler
11.5 The linker
12 Examining compiled files
12.1 Identifying files
12.2 Examining the symbol table
12.3 Finding dynamically linked libraries
13 Getting help
Further reading
Acknowledgements
Other books from the publisher
Free software organizations
GNU Free Documentation License
ADDENDUM: How to use this License for your documents
The purpose of this book is to explain the use of the GNU C and C++ compilers, gcc and g++. After reading this book you should understand how to compile a program, and how to use basic compiler options for optimization and debugging. This book does not attempt to teach the C or C++ languages themselves, since this material can be found in many other places.
Experienced programmers who are familiar with other systems, but new to the GNU compilers, can skip the early sections of the chapters “Compiling a C program”, “Using the preprocessor” and “Compiling a C++ program”. The remaining sections and chapters should provide a good overview of the features of GCC for those already know how to use other compilers.