Preparing the Compiler and Linker Environment

Debugging information is put into .o files by compilers. The level and format of information is controlled by compiler options.

With the Intel® C++ or Fortran Compiler, use the -g option. For example:

% icc -g hello.c
…
% icpc -g hello.cpp

With the GNU* Compiler Collection, (GCC) use the -g option. On some older versions of GCC, this option might generate DWARF-1. If so, use the -gdwarf-2 option. For example:

% gcc -gdwarf-2 hello.c
…
% g++ -gdwarf-2 hello.cpp

See your compiler's documentation for more details.

The debugging information is propagated into the a.out (executable) or .so (shared library) by the ld command.

If you are debugging optimized code, using -g automatically adds -O0.

See the Debugging Optimized Code section of this manual and the appropriate compiler documentation for information about -g and related extended debug options and their relationship to optimization.

See Also


Submit feedback on this help topic

Copyright © 1996-2010, Intel Corporation. All rights reserved.