Makefile Help

This is a discussion on Makefile Help within the Tech Board forums, part of the Community Boards category; Hello again guys. I would just like to ask for some help regarding the makefile I used for the inttohex ...

  1. #1
    Registered User
    Join Date
    Jun 2007

    Makefile Help

    Hello again guys. I would just like to ask for some help regarding the makefile I used for the inttohex program. It would not work and it would just say Missing separator. Stop..

    Hope somebody could help. Here's the makefile:

    # makefile for exercise on linked lists, files, searching and sorting
    CFLAGS=-g -W -Wall -I.
            $(CC) $(CFLAGS) $(OBJECTS) -o $(PROGNAME)
    inttohex.o: inttohex.c $(HEADERS)
            $(CC) -c $(CFLAGS) -o inttohex.o
    .PHONY: clean ctags
    tags: ctags
            ctags -R
            rm -rf $(OBJECTS) $(PROGNAME)

  2. #2
    Registered User
    Join Date
    Jan 2006
    That's because you're using spaces instead of tabs in lines where command has to be executed. For example
            $(CC) $(CFLAGS) $(OBJECTS) -o $(PROGNAME)
    must be indented with tab not with 8 spaces.
    Beside this, in the line
            $(CC) -c $(CFLAGS) -o inttohex.o
    you are not giving the source file to the compiler, so it cannot compile. Add inttohex.c after -c flag:
             $(CC) -c inttohex.c $(CFLAGS) -o inttohex.o
    Maybe there are more errors, that's what I saw immediately.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    You shouldn't need to pass -r to rm, because I don't think it's going to be passed any directories.

    Also, there is an implicit rule to compile .c files into .o files, so you can just use this:
    inttohex.o: inttohex.c $(HEADERS)
    leaving out the "$(CC) -c $(CFLAGS) -o inttohex.o".

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Moved to Tech Board since it does not directly concern C programming.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 10:50 PM
  3. unix makefile won't work but works in Dev C++
    By jk1998 in forum C++ Programming
    Replies: 1
    Last Post: 06-09-2007, 03:54 PM
  4. makefile blues....
    By WaterNut in forum C Programming
    Replies: 6
    Last Post: 05-30-2005, 08:22 PM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM

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