0

This is my makefile:

OBJECTS = main.o

CFLAGS = -g -wall

NAME = make

CC = gcc

build: $(OBJECTS)

    $(CC) $(CFLAGS) $(OBJECTS) -o $(NAME)

I'm getting below error when I tried to make(Applied tab before gcc command) :

makefile:6: *** missing separator. Stop.

How can I fix this?

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
  • 5
    Possible duplicate of [Error in make command makefile:18: \*\*\* missing separator. Stop](https://stackoverflow.com/questions/10097193/error-in-make-command-makefile18-missing-separator-stop) – Oliver Charlesworth Jun 18 '17 at 09:07
  • Delete the empty line, `make` is very picky about its syntax. Also you should always use tabs to indent recipe commands and never spaces. – Guido Jun 18 '17 at 09:10
  • Thanks Oliver for your suggestion . I've deleted empty lines and the line next to target "build" started with tab . Still I'm getting same error – Goutham Reddy Jun 18 '17 at 09:17
  • Only the line `$(CC) ...` should begin with a tab. – Beta Jun 18 '17 at 18:33
  • Does this answer your question? [Make error: missing separator](https://stackoverflow.com/questions/920413/make-error-missing-separator) – SuperStormer Feb 18 '23 at 04:30

1 Answers1

0

First of all, it looks like you have spaces instead of tab.

As for the Makefile itself, I'd make it little bit simpler. For a source file main.c:

int main() {
  return 0;
}

I would go with Makefile:

CFLAGS = -g -wall
CC = gcc

main: main.c
        $(CC) $(CFLAGS) $< -o $@
Oo.oO
  • 12,464
  • 3
  • 23
  • 45