Thread: debugging with a makefile

  1. #1
    Registered User
    Join Date
    Sep 2011

    debugging with a makefile

    I have written a program that prints out all the permutations of the characters in a string literal. I have a segmentation fault and for the first time using a debugger (gdb). How do I include the -g sign in the makefile. Here is the make file
    list: perm.o data_list.o stack_list.o cmdline.o
    	$(CC) -o perm perm.o data_list.o stack_list.o cmdline.o
    perm.o: perm.c data.h stack.h cmdline.h
    	$(CC) -o perm.o perm.c $(CARGS)
    data_list.o: data_list.c data.h
    	$(CC) -o data_list.o data_list.c $(CARGS)
    stack_list.o: stack_list.c stack.h
    	$(CC) -o stack_list.o stack_list.c $(CARGS)
    cmdline.o: cmdline.c cmdline.h
    	$(CC) -o cmdline.o -c cmdline.c $(OPTS)
    When I type make in the cmd prompt I get -g attached at the end. like so
    gcc -o data_list.o data_list.c -g

    The examples on the net show that -g should follow gcc . I get the error

    In function `_start':
    (.text+0x20): undefined reference to `main'

    So I got two problems. It does not even compile and once I go to gdb I and I type any command (for example list) I get the error no symbol table. advice please.

    I see I need to have -c option there my bad. Please answer the second question
    Last edited by ali.franco95; 09-29-2011 at 10:50 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    So what file in there actually has main in it?

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. optimization and debugging options in Makefile
    By lehe in forum C++ Programming
    Replies: 5
    Last Post: 08-27-2009, 01:34 PM
  2. Not sure how to put this into a Makefile
    By redruby147 in forum C Programming
    Replies: 4
    Last Post: 07-07-2009, 12:45 PM
  3. makefile
    By shuo in forum C++ Programming
    Replies: 1
    Last Post: 11-18-2007, 01:41 AM
  4. difference makefile
    By Bargi in forum Linux Programming
    Replies: 7
    Last Post: 10-28-2007, 02:08 PM
  5. makefile
    By rahulsk1947 in forum C Programming
    Replies: 2
    Last Post: 04-27-2006, 09:12 PM