GCC Debugging and Makefile issues

This is a discussion on GCC Debugging and Makefile issues within the C Programming forums, part of the General Programming Boards category; Ok, I've tried running gcc with -g a number of ways but GDB always says "no debugging symbols found." I'm ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    161

    GCC Debugging and Makefile issues

    Ok, I've tried running gcc with -g a number of ways but GDB always says "no debugging symbols found." I'm using MinGW/MSYS with GCC 4.7.2 on Win7.

    My makefle is definitely messy, but the only thing I ever really had to go on was the crap Dev-C++ created when I was using that early on. Do I need something more than -g? Or does this copy of GCC just not compile debugging symbols? There are no compile errors and the program works, but I can't get it to add debugging symbols for GDB for anything. Every time I break something I have to debug the hard way.

    Code:
    # Project: RenegadeEx
    
    NAME  = rex.exe
    
    CC = gcc
    WINDRES = windres
    RES  = rex.res
    OBJ  = $(OBJPATH)rex.o $(OBJPATH)tab_hook.o $(OBJPATH)tab_results.o $(OBJPATH)tab_search.o $(OBJPATH)tab_settings.o $(OBJPATH)lib_api.o $(OBJPATH)lib_fileio.o $(OBJPATH)lib_listview.o $(OBJPATH)lib_misc.o $(OBJPATH)lib_rex.o $(OBJPATH)lib_search.o $(OBJPATH)lib_memory.o $(OBJPATH)$(RES)
    LDFLAGS = -s -mwindows -lwsock32 -lcomctl32 -lpsapi
    CFLAGS = -O2 -s
    OBJPATH = obj/
    GLOBALINCLUDES = _types.h rex.h lib_fileio.h lib_misc.h lib_search.h
    
    
    .PHONY: all
    
    all: $(NAME)
    
    
    clean:
    	rm -f $(OBJ)
    
    Debug: $(NAME)
    
    cleanDebug: clean
    
    $(NAME): $(OBJ)
    	$(CC) $(OBJ) -o $(NAME) $(LDFLAGS)
    
    $(OBJPATH)rex.res: rex.rc rex_gui.h
    	$(WINDRES) -i rex.rc -J rc -o $(OBJPATH)rex.res -O coff
    
    $(OBJPATH)rex.o: rex.c rex_gui.h $(GLOBALINCLUDES)
    	$(CC) -c rex.c -o $(OBJPATH)rex.o $(CFLAGS)
    
    #Tabs
    
    $(OBJPATH)tab_hook.o: tab_hook.c rex_gui.h $(GLOBALINCLUDES)
    	$(CC) -c tab_hook.c -o $(OBJPATH)tab_hook.o $(CFLAGS)
    
    $(OBJPATH)tab_results.o: tab_results.c rex_gui.h $(GLOBALINCLUDES)
    	$(CC) -c tab_results.c -o $(OBJPATH)tab_results.o $(CFLAGS)
    
    $(OBJPATH)tab_search.o: tab_search.c rex_gui.h $(GLOBALINCLUDES)
    	$(CC) -c tab_search.c -o $(OBJPATH)tab_search.o $(CFLAGS)
    
    $(OBJPATH)tab_settings.o: tab_settings.c rex_gui.h $(GLOBALINCLUDES)
    	$(CC) -c tab_settings.c -o $(OBJPATH)tab_settings.o $(CFLAGS)
    
    #Libraries
    
    $(OBJPATH)lib_api.o: lib_api.c $(GLOBALINCLUDES)
    	$(CC) -c lib_api.c -o $(OBJPATH)lib_api.o $(CFLAGS)
    
    $(OBJPATH)lib_fileio.o: lib_fileio.c lib_fileio.h _types.h
    	$(CC) -c lib_fileio.c -o $(OBJPATH)lib_fileio.o $(CFLAGS)
    
    $(OBJPATH)lib_listview.o: lib_listview.c $(GLOBALINCLUDES)
    	$(CC) -c lib_listview.c -o $(OBJPATH)lib_listview.o $(CFLAGS)
    
    $(OBJPATH)lib_memory.o: lib_memory.c $(GLOBALINCLUDES)
    	$(CC) -c lib_memory.c -o $(OBJPATH)lib_memory.o $(CFLAGS)
    
    $(OBJPATH)lib_misc.o: lib_misc.c lib_misc.h _types.h
    	$(CC) -c lib_misc.c -o $(OBJPATH)lib_misc.o $(CFLAGS)
    
    $(OBJPATH)lib_rex.o: lib_rex.c $(GLOBALINCLUDES)
    	$(CC) -c lib_rex.c -o $(OBJPATH)lib_rex.o $(CFLAGS)
    
    $(OBJPATH)lib_search.o: lib_search.c lib_search.h _types.h
    	$(CC) -c lib_search.c -o $(OBJPATH)lib_search.o $(CFLAGS)

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,748
    I do not know about the "-s" option in linking.
    From http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
    Remove all symbol table and relocation information from the executable.
    Code:
    LDFLAGS = -s -mwindows -lwsock32 -lcomctl32 -lpsapi
    I know the "-s" in Compiler option does stripping (I can NOT find a link to confirm this is a Compiler Option.)
    [I am starting to think it might only be a linker option; I never used it except via IDE]
    Code:
    CFLAGS = -O2 -s
    I did NOT find the "-g" in your makefile.

    I did find the "-s"; This option causes the debugging symbols to be stripped (removed).

    Do, remove the "-s" option and add the "-g" option and try again.

    Tim S.
    Last edited by stahta01; 03-24-2013 at 12:07 PM.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    161
    Hah. Ok, that solves the debugging issue. Thanks. It'd be nice if I knew the right way to set that file up. I can't even figure out what half those arguments are "-O2" ??? "-O coff" ???

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    2,905
    You may want to read the documentation for gcc. Here is a list of most of the options for the compiler. Option Summary The -O2 is one of the optimization switches.

    Jim

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    161
    Thanks. I'm also curious if stripping debug info with -s matters? I mean, if it's an open source project anyway, I don't care about leaving debug symbols in the release. I'm just wondering if it affects performance at all.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    2,748
    Quote Originally Posted by Viper187 View Post
    Thanks. I'm also curious if stripping debug info with -s matters? I mean, if it's an open source project anyway, I don't care about leaving debug symbols in the release. I'm just wondering if it affects performance at all.
    I have heard that it is normally done to make the size of the download smaller.

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. debugging with a makefile
    By ali.franco95 in forum C Programming
    Replies: 1
    Last Post: 09-30-2011, 04:09 AM
  2. Debugging issues
    By melodia in forum C Programming
    Replies: 1
    Last Post: 11-21-2010, 07:56 AM
  3. optimization and debugging options in Makefile
    By lehe in forum C++ Programming
    Replies: 5
    Last Post: 08-27-2009, 02:34 PM
  4. Debugging Issues
    By jl864405 in forum C Programming
    Replies: 6
    Last Post: 06-05-2009, 06:40 PM
  5. difference makefile makefile.am makefile.in
    By Bargi in forum Linux Programming
    Replies: 7
    Last Post: 10-28-2007, 03:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21