Sam
Sam

Reputation: 485

makefile, missing separator error

I written a very simple makefile for a c++ program, but it returns makefile:2: *** missing separator. Stop. error. What's wrong with it?

makefile:

all:
[tab]g++ function.cpp -o out

I compile the program in cygwin and Ubuntu.

thanks

Upvotes: 7

Views: 21336

Answers (4)

Shagun Sodhani
Shagun Sodhani

Reputation: 3727

As pointed out here, the most common cause for this error is that lines are indented with whitespaces when make expects tab characters.

Upvotes: 3

billz
billz

Reputation: 45410

You need a real tab instead of space in front of g++ command, also you don't need to put function.h in g++ command.

all:
    g++ function.cpp  -o out
^^^ tab here  

Upvotes: 9

TieDad
TieDad

Reputation: 9889

The second line must start with a tab.

The first line is target, then you define rules below target. Rule lines must all start with tab.

Upvotes: 2

user529758
user529758

Reputation:

Instead of 4 (8?) spaces, use <tab> at the beginning of the second line.

Upvotes: 3

Related Questions