0

I am using make and debugging symbols are not getting generated. Here is my makefile:

program: ui.o data.o string.o
        c99 -ggdb -o program2 ui.o data.o string.o

clean :
        rm -f program2

ui.o : ui.c data.h
        c99 -ggdb -c ui.c

data.o : data.c data.h
        c99 -ggdb -c data.c

string.o : string.c string.h
        c99 -ggdb -c string.c

How can I generate debugging symbols? When I run gdb using gdb program2 it gives the warning "No debugging symbols found".

Tyler Durden
  • 11,156
  • 9
  • 64
  • 126
  • Is `c99` a valid call to the compiler ? I think you should call it like this instead (and keep the other flags) : `gcc -std=c99` – Tim Jul 11 '16 at 13:02
  • 1
    It generates the executable. I was told that running c99 is the normal way to compile c99 code using gcc, according to Thomas Pornin's answer here: http://stackoverflow.com/questions/2193634/setting-std-c99-flag-in-gcc – Tyler Durden Jul 11 '16 at 13:04
  • Okay thanks I didn't know that. I guess I'm using a too old version of gcc. Well since it's not the problem I can't help you more, sorry. – Tim Jul 11 '16 at 13:07

1 Answers1

1
  1. Your Makefile builds program2, but pretends to build program (i.e. the target on the first line is wrong).
  2. Your clean target should also clean *.o, otherwise make clean; make will only relink program, but will not recompile any objects in it.

One of the above factors is a likely explanation for missing debug symbols you've observed.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362