Quick Fix: Ensure that all actions of every rule start with a tab in the Makefile. Without a tab, Make will not be able to identify the action and execute it correctly.
The Solutions:
Solution 1: Tabs are required to start each recipe
Make defines a tab is required to start each recipe. All actions of every rule are identified by tabs. If you prefer to prefix your recipes with a character other than a tab, you can set the .RECIPEPREFIX variable to an alternate character.
To check, use the cat -e -t -v makefile_name
command.
It shows the presence of tabs with ^I
and line endings with $
. Both are vital to ensure that dependencies end properly and tabs mark the action for the rules so that they are easily identifiable to the make utility.
Example:
Kaizen ~/so_test $ cat -e -t -v mk.t
all:ll$ ## here the $ is end of line ...
$
ll:ll.c $
^Igcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<$
## the ^I above means a tab was there before the action part, so this line is ok .
$
clean :$
\rm -fr ll$
## see here there is no ^I which means , tab is not present ....
## in this case you need to open the file again and edit/ensure a tab
## starts the action part
Solution 2: Correcting Make Target Separator
The error "missing separator" occurs when the makefile lacks a colon (:) separator between the target and its dependency. In this case, the target "ll" in line 2 and the dependency "ll.c" in line 3 are not separated by a colon.
To fix this, add a colon after the target name "ll" in line 2. The corrected makefile should look like this:
all: ll
ll: ll.c
gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<
clean:
\rm -fr ll
Solution 3: Fixing Make Error “Missing Separator”
In a makefile, each line must have a command preceded by a tab character, not a whitespace. This is the proper syntax for a makefile rule.
In the provided makefile, line 4 contains a command that does not have a tab character before it. This error can be fixed by inserting a tab before the command:
ll: ll.c
cc -c -Wall -Werror -O2 ll.c -o ll $@ $<
Additionally, on the same line, there is a typographical error. The command should be rm -fr ll
instead of \rm -fr ll
, and it should also be preceded by a tab. The corrected line becomes:
clean:
rm -fr ll
With these corrections, the makefile will work properly.
Solution 4: Correct Makefile Syntax
To fix the error "missing separator," ensure that your Makefile follows the correct syntax. In a Makefile:
- Lines of Make code should be indented with spaces only.
- Lines of Bash/shell code should be indented with tabs only.
In your Makefile, the error is likely due to inconsistent indentation:
ll:ll.c
gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<
Here, the line with the gcc
command is indented with a mix of spaces and tabs, which is not allowed.
To fix it, indent the line consistently with either spaces or tabs:
ll: ll.c
gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<
Or:
ll: ll.c
\tgcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<
Solution 5: Install Makefile Support Plugin for PyCharm
To resolve the error, install the Makefile Support Plugin in PyCharm:
Steps:
- Open Preferences (
Cmd
+,
for macOS,Ctrl
+,
for Windows/Linux). - Navigate to Plugins -> Marketplace.
- Search for Makefile Support, install it, and restart PyCharm.
This plugin provides syntax highlighting and improved support for Makefiles, resolving the "missing separator" error.