Compiling C/C++ Programs For gdb Support
- An executable program needs to have "debug symbols" in order to be
properly debugged under gdb.
- To compile a single-file program with debug info, use the '-g' flag:
gcc -g prog.c -o prog
- The same manner works with g++ for C++ programs.
- Use '-g' also when compiling separate source files of a multi-file
program.
- You don't need to compile all source files of a program with debug
information...
- ... but then you'll only be able to step through the sources that were
compiled with '-g'.
Originally written by
guy keren