No debugging symbols in gdb even when compiling with -g flag

前端 未结 6 395
一个人的身影
一个人的身影 2021-01-17 12:54

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 symb

相关标签:
6条回答
  • 2021-01-17 13:37

    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.

    0 讨论(0)
  • 2021-01-17 13:50

    I am not sure, but I think you need -g even while linking.

    0 讨论(0)
  • 2021-01-17 13:52

    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>
    
    0 讨论(0)
  • 2021-01-17 13:57

    try to replace

    $(BIN): $(OBJ)
     $(CPP) $(LDFLAGS) $(OBJ) -o $(BIN) $(LIBS)
    

    with

    $(BIN): $(OBJ)
     $(CPP) $(CFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS) $(LIBS)
    

    (edit) Note: -c option will not work with executable

    0 讨论(0)
  • 2021-01-17 14:00

    Ahh. I'm very sorry. It turns out the "clean:" portion of my makefile is broken. Thus when I used make clean nothing happened. Deleting the .o files manually fixed the problem. The flags work perfectly now. Thanks to everyone who posted anyway! This can be deleted now.

    0 讨论(0)
  • 2021-01-17 14:00

    I had the same issue when using a makefile I inherited on some old F77 code. I tried all the flags people recommend (-g -ggdb ...etc.) the solution was run make clean If you don't have that or know what it means, basically delete all the compiled (.o) files.

    the makefile didn't know to recompile since only flags were changed, so I wasn't actually compiling with -g or -ggdb when I thought it was. Hope this helps someone!

    0 讨论(0)
提交回复
热议问题