Thread: using a makefile / gdb info

  1. #1
    Registered User dinjas's Avatar
    Join Date
    Feb 2005
    Location
    Vancouver, Washington
    Posts
    40

    using a makefile / gdb info

    I've been writing my code in the Unix environment compiling with gcc and using gdb for debugging. I'm having problems with the - g option with gcc when I'm using a makefile. Consider the following makefile:
    Code:
    rbtree:main.o insert.o delete.o
            gcc -lm -g -o rbtree main.o insert.o delete.o
    
    main.o:main.c
            gcc -c main.c -o main.o
    
    delete.o:delete.c
            gcc -c delete.c -o delete.o
    
    insert.o:insert.c
            gcc -c insert.c -o insert.o
    
    clean:
            rm -f core *.o rbtree
    My program compiles fine, but when I run gdb to debug, there is no line number information in the file. ??? I can compile from the command line and all is well, but I'd like to be able to use the makefile. Anybody see anything terribly wrong that I'm doing. (i realize that I don't need the
    Code:
     gcc -c delete.c -o delete.o
    for each target after rbtree, but is there anything else? Thanks,
    jason
    straight off the heap

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    You need to compile the source code with the -g option. Right now you only have it at the link stage. Put -g with every source file

  3. #3
    Registered User dinjas's Avatar
    Join Date
    Feb 2005
    Location
    Vancouver, Washington
    Posts
    40
    Thanks, that did the trick.
    straight off the heap

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. buffered vs unbuffered question
    By Overworked_PhD in forum Linux Programming
    Replies: 6
    Last Post: 07-04-2008, 04:57 PM
  2. Contiguous Array version of Linked List
    By ampersand11 in forum C Programming
    Replies: 19
    Last Post: 10-07-2007, 03:05 AM
  3. Too much output in GDB
    By MacNilly in forum Tech Board
    Replies: 0
    Last Post: 09-13-2006, 12:45 PM
  4. does gdb lie?
    By dinjas in forum C Programming
    Replies: 8
    Last Post: 03-10-2005, 05:17 PM
  5. Help doing an e-mail program in c...
    By Tyler_Durden in forum C Programming
    Replies: 88
    Last Post: 01-02-2005, 03:12 PM