Makefile
Programming Errors
Debugging
Code Compilation
Separator Error

Makefile:4: *** missing separator. Stop. How to fix it

Codemia Knowledge Hub ·

make stops with makefile:4: *** missing separator. Stop. when line 4 breaks Makefile syntax, almost always because a recipe line starts with spaces instead of a tab. Replace the leading spaces on that line with a single real tab character.

What make expects on that line

A Makefile is a set of rules, each made of:

  1. A target: the file make creates or updates.
  2. Prerequisites: the input files used to build the target.
  3. A recipe: the commands make runs to build the target.

The basic syntax:

makefile
target: prerequisites
[TAB] recipe

[TAB] stands for a literal tab character, which must start every recipe command. The error appears when the tab is missing, replaced by spaces, or the rule is otherwise malformed. The number after makefile: is the line where make found the problem.

Causes and fixes

  • Spaces instead of a tab: the most common cause. Start recipe lines with a tab.
  • Inconsistent indentation: use only tab characters before recipes.
  • Whitespace-only lines: a line with only spaces or tabs and no command can be misread by make.

Broken example:

makefile
all: hello

    gcc -o hello hello.c

The gcc line is indented with spaces, which triggers the error.

Fixed version:

makefile
all: hello
[TAB]gcc -o hello hello.c

Replace [TAB] with an actual tab character in your Makefile.

Preventing it in your editor

Configure your editor or IDE to insert tabs rather than spaces in Makefiles. You can also run make -n (or make --just-print) to print the commands that would run without executing them, which helps spot problems.

Quick reference

Issue DescriptionSolution
Spaces used instead of tabsReplace spaces with a tab
Misaligned text in recipesEnsure all commands in recipes are tabbed
Missing recipe commandsAdd the necessary command after the target

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Interview Questions practice on Codemia

Over 11,000 interview practice questions for 300+ companies, searchable by company and role.

Browse interview questions