How to fix Makefile missing separator error

By Steve Claridge on 2022-10-03.

I run make on a C or C++ project and get the following error

Makefile:5: *** missing separator. Stop.

My Makefile is very simple and looks like this:

hello: *.cpp
   g++ -o hello hello.cpp

The reason I was getting the error was because the command line did not start with a tab, in my editor I'd just hit the spacebar a few times to indent the g++ -o hello hello.cpp line. The Makefile spec says

Target rules are formatted as follows:

target [target...]: [prerequisite...][;command]
[<tab>command
<tab>command
...]

So just make sure you hit tab to indent in a Makefile.