I am trying to compile my program with debugging symbols for use in gdb. I have added the -g flag to my makefile but I still get "Reading symbols from ...(no debugging symbols found)" when I load the program in gdb. What is wrong??
Here is a stripped down example of my makefile which should have the relevant bits:
CPP = g++
CFLAGS = -c -g -Wall
$(BIN): $(OBJ)
$(CPP) $(LDFLAGS) $(OBJ) -o $(BIN) $(LIBS)
<test.o>: <test.cpp>
$(CPP) $(CFLAGS) <test.cpp> -o <test.o>
If you'd like to see the whole thing you can go here instead, though I don't think it's necessary:
http://pastebin.com/vGNjy0ga
Miscellaneous notes.. I'm compiling with MinGW on Windows and I have SFML and OpenGL as dependencies.
And no, the -s flag is nowhere to be found in my makefile.
A Debugging Symbol Table maps instructions in the compiled binary program to their corresponding variable, function, or line in the source code. This mapping could be something like: Program instruction ⇒ item name, item type, original file, line number defined.
To add additional symbols you might use add-symbol-file . The add-symbol-file command reads additional symbol table information from the file filename. You would use this command when filename has been dynamically loaded (by some other means) into the program that is running.
The -g flag tells the compiler to generate debugging information.
I dont have much experience with Mingw but try replacing -g with -ggdb. This may solve your problem. According to gcc man page
Produce debugging information for use by GDB. This means to use the most expressive format available (DWARF 2, stabs, or the native format if neither of those are supported), including GDB extensions if at all possible.
I think you need -g
when linking the object into a binary code.
CPP = g++
CFLAGS = -g -Wall
$(BIN): $(OBJ)
$(CPP) $(CFLAGS) $(OBJ) -o $(BIN) $(LDFLAGS) $(LIBS)
<test.o>: <test.cpp>
$(CPP) $(CFLAGS) -c <test.cpp> -o <test.o>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With