'make' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# 'make' is not recognized as an internal or external command

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.

make is not recognized as internal or external command

If you have Chocolatey installed:

  1. Click on the Search bar and type PowerShell.

  2. Right-click on the PowerShell application and click "Run as administrator".

run powershell as administrator

  1. Run the following command to install make.
PowerShell
choco install make -y
If you don't have Chocolatey installed, you have to install it first.

To install Chocolatey:

  1. Open PowerShell as an administrator.

run powershell as administrator

  1. Run the following command.
PowerShell
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'))

windows install chocolatey

  1. Wait for the command to complete.
  2. Type choco to make sure Chocolatey is installed.

windows verify chocolatey installed

Now that you have Chocolatey installed, run the following command to install make.

PowerShell
choco install make -y

Note that your shell should still be run using elevated permissions.

chocolatey install make

Now you should be able to use the make command.

PowerShell
make --version

make print version

To create a simple Makefile:

  1. Click on the Search bar, type cmd and start the Command Prompt.
  2. Start a notepad editor by typing notepad in the shell.
cmd
notepad

open notepad

  1. Click on "File" > "Save as".

click file save as

  1. Name your file "Makefile" with double quotes around the name. The double quotes are important because we need to create a file named Makefile without an extension.

name file makefile

  1. Click on "Save".

  2. 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.

Makefile
first: echo "first message" second: echo "second message"
Make sure to indent your commands in a 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.

cmd
make

run make command windows

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.

cmd
make second

name file makefile

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.