Thread: help with makefile error

  1. #1
    Registered User
    Join Date
    Apr 2014
    Posts
    26

    help with makefile error

    I have the following makefile

    Code:
    CFLAGS=-ansi -Wall -Wextra -pedantic -o2
    
    test: test.o function.o
        gcc $ (CFLAGS) -o test test.o function.o
    
    .PHONY: clean
    
    clean:
        rm -f *.o
    but when i write make on the terminal it always says:

    gcc (CFLAGS) -o test test.o function.o
    /bin/sh: 1: Syntax error: word unexpected (expecting ")")
    make: *** [test] Error 2

    what am i doing wrong? I tried looking everywhere on the internet and i cant seem to find what is wrong....

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > CFLAGS=-ansi -Wall -Wextra -pedantic -o2
    Optimisation flags use upper case O, not lower case o

    > gcc $ (CFLAGS) -o test test.o function.o
    There should be no space between $ and (
    Also, calling a program 'test' is likely to conflict with the built-in shell command of the same name.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2014
    Posts
    26
    You are totally right it finally works! Thank you !

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compile error with Makefile...
    By LockTim in forum C++ Programming
    Replies: 3
    Last Post: 09-11-2013, 11:04 AM
  2. compiling makefile - error
    By ilans11il in forum C Programming
    Replies: 4
    Last Post: 02-05-2013, 11:51 AM
  3. makefile error
    By shuo in forum Tech Board
    Replies: 4
    Last Post: 11-21-2007, 07:42 AM
  4. difference makefile makefile.am makefile.in
    By Bargi in forum Linux Programming
    Replies: 7
    Last Post: 10-28-2007, 02:08 PM
  5. makefile error
    By Renegade in forum C++ Programming
    Replies: 0
    Last Post: 07-15-2005, 04:54 PM