Last updated: Apr 4, 2024
Reading time·3 min
The error "'make' is not recognized as an internal or external command,
operable program or batch file" occurs when we run the make
command on Windows
without having make
installed. To solve the error, install make
using
Chocolatey.
If you have Chocolatey installed:
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".
make
.choco install make -y
To install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco
to make sure Chocolatey is installed.Now that you have Chocolatey installed, run the following command to install
make
.
choco install make -y
Note that your shell should still be run using elevated permissions.
Now you should be able to use the make
command.
make --version
To create a simple Makefile:
cmd
and start the Command Prompt.notepad
in the shell.notepad
Makefile
without an extension.Click on "Save".
Add the following targets to the Makefile
.
Note that copy-pasting the commands below might fail because you must use tabs
for the indentation in a Makefile
.
It's much better to manually type the 4 lines and make sure to use tabs for the indentation.
first: echo "first message" second: echo "second message"
Makefile
using tabs and not spaces, otherwise, the make
command will fail.Now, ensure your shell is in the same folder as the Makefile
and run the
make
command.
make
When you run the make
command without specifying a target, the first target is
run.
You can specify a target immediately after the make
command.
make second
You can learn more about the related topics by checking out the following tutorials: