How to generate Debug symbols with Makefile for C? [Linux]

ArielBH picture ArielBH · Dec 21, 2009 · Viewed 35k times · Source

I'm trying to use GDB and KDEvelop to debug a console app under Knoppix VM. KDevelop and GDB don't break at my breakpoints. I suspect it's because they don't have debug symbols.

If I'm correct how do I need to change my Makefile to create those. Maybe the problem is somewhere else?

Regards, Ariel

Answer

Include -g in the flags sent to the compiler and linker. The default variables for this are CFLAGS and LDFLAGS respectively.

The second step: exclude -s from flags (-s means strip)