0
votes

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?

1
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
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 errorGoutham Reddy
Only the line $(CC) ... should begin with a tab.Beta

1 Answers

0
votes

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 $@