How to generate debug symbols using Makefile for C? [Linux]

I am trying to use GDB and KDEvelop to debug a console application under Knoppix VM. KDevelop and GDB don't break into my breakpoints. I suspect this because they do not have debugging symbols.

If I'm right, how do I need to modify my Makefile to create them. Maybe the problem is elsewhere?

Regards, Ariel

+4
source share
3 answers

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

Second step: exclude -s from flags ( -s means strip )

+11
source

If you can see the source and set a breakpoint, you probably have debugging symbols. However, the usual sequence:

 gcc -g -o (outputname) (source files...) gdb outputname 

Give more details about what you are doing and what messages you see, and we can be more specific.

+4
source

Full example:

 CFLAGS =-g all: program.o gcc -o program program.o 

CFLAGS applies here to both the compiler and the linker.

0
source

All Articles