makefile blues....

This is a discussion on makefile blues.... within the C Programming forums, part of the General Programming Boards category; Hi, based off some errors I got compiling last week, it was recommended I create a makefile to include some ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    164

    Question makefile blues....

    Hi, based off some errors I got compiling last week, it was recommended I create a makefile to include some links for necessary libs.

    I began researching make and creating makefiles and found some good examples to work from but the make file I created is blowing up on me.

    Have I created a bad makefile or is it finding issues with my source code? I know thats a vague question I'm trying to get someone to read the code, just not sure if I am grasping the makefile concept or not and wanted to know if anyone see's an obvious mistake. Thanks-

    the error while running make is:
    Code:
    make: Fatal error in reader: Makefile, line 17: Unexpected end of line seen
    the actual make file is:
    Code:
    INCL   = utilserv.h
    SRC    = simpletest.c
    OBJ    = $(SRC:.c=.o)
    LIBS   = -lsocket -lcomctl32
    EXE    = a.exe
    
    # compiler stuff
    CC      = gcc
    CFLAGS  = -O3
    LDFLAGS =  -o $(EXE) $(LIBS)
    CFDEBUG = -g -DDEBUG $(LDFLAGS)
    RM      = rm -f
    
    # create object files
    %.o: %.c
        $(CC) -c $(CFLAGS) $*.c -o $*.o
    
    # linker objects
    $(EXE): $(OBJ)
        $(CC) $(OBJ) menu.o $(LDFLAGS) -mwindows
    
    # object-dependent libraries
    $(OBJ): $(INCL)
    # make debug
    debug:
        $(CC) $(CFDEBUG) $(SRC)
    
    # make clean
    clean:
        $(RM) $(OBJ) $(EXE)

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Code:
    # create object files
    %.o: %.c
        $(CC) -c $(CFLAGS) $*.c -o $*.o
    I don't think there is supposed to be a space between the : and %.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    164
    Thanks for the reply, I tried removing the space between the : and %, but still got the same error. I'm not familiar with the syntax for unix with make, I'm new to programing in the unix environment.

    I tried compiling against a known good .c file and it still failed with the same error, so I'm pretty sure its an error with how my makefile is setup, I just don't enough about to find the problem.... Thanks again for any help

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Maybe there's something in one of these; or man make.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    164
    Thanks Dave.

    Google is always a good place to look. I have not been able to find my issue, I'm sure its just some simple syntax issue on my part so I will start writing from scratch and see if I catch it.

    Thanks for the replies-

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Assuming you are indenting your rules with tab characters make sure you don't have any extra/stray spaces there, too.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #7
    Registered User
    Join Date
    May 2004
    Posts
    164
    As it turns out Ken you are correct. Thats what I get for being lazy! and doing a paste and copy of an example and trying to fill in the blanks. Thanks again to all. Sometimes shortcuts are not as short as they seem. But I am learning!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with makefile
    By New_Programmer in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2009, 04:55 PM
  2. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 10:50 PM
  3. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM
  4. about Makefile and Macro
    By tom_mk in forum C++ Programming
    Replies: 1
    Last Post: 09-18-2003, 01:07 PM
  5. makefile woes
    By Grifftt in forum C Programming
    Replies: 2
    Last Post: 12-06-2002, 03:43 PM

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