1
votes

simple question. I want to be able to run my executable with a program like ddd or kdbg. How do I add the debugging flag so that kdbg will show the source code?

My make file macros look like

CC = gcc

CFLAGS = `pkg-config --cflags gtk+-2.0`

LIBS = `pkg-config --libs gtk+-2.0`

I've tried:

CFLAGS = `pkg-config --cflags gtk+-2.0` -g

and

CC = gcc -g

but neither work. kdbg opens without showing code.

Fixed: The problem was that I wasn't deleted the o files, and so the make was just relinking those existing object files without recompiling them.

2
The link that you provided is about building Glib itself, most likely you don't have to compile it manually. Please, clarify, whether you want to build Glib or just to link it with you program.Eldar Abusalimov
Yeah, no. All I want to do is include debugging info. Link removed.dwjohnston

2 Answers

2
votes

The problem was that I wasn't deleted the o files, and so the make was just relinking those existing object files without recompiling them.

1
votes

You have to somehow pass -g flag to compiler and linker.

The simplest way is to append it to CFLAGS and LDFLAGS variables by adding the following lines to your script:

...

ifdef DEBUG

CFLAGS  += -g
LDFLAGS += -g

endif

Now one can pass DEBUG flag to Make to enable building debuggable binary.

make DEBUG=1