How to install 'make' on Windows Machine

What is make and Makefile ? Installing make on windows.

How to install 'make' on Windows Machine

Make or 'make' is a Unix command line utility that is designed to start the execution of a script. Being a utility, it uses the 'make' command that is used to trigger/run series of commands commonly called as scripts. ( Similar to npm being a utility and you use 'npm' command to install dependencies or run scripts ) .

But how does 'make' know what script to run ? Direct answer, through a 'Makefile' ! Uhmm, But, What is a Makefile ? You provide a file in your project source directory that tells 'make' how your application is constructed. This file is called the makefile. ( Similar to how a 'package.json' file tells npm which scripts to run. ) The Makefile includes scripts for each of the make commands you are directed to execute. For instance, On executing the 'make start' command, make will go through your Makefile and search for a script with name 'start', and execute the commands corresponding to it.

Now that we know what 'make' and Makefiles are, Lets see how we install it correctly on Windows. ( We will make it work too :P )

Before we proceed, A quick information !

There are two different makes included with MinGW, 'mingw32-make' (MinGW's make) and make (MSYS's make). With MSYS version of make you can write commands much the same as you would on Unix or Linux system, while with the native mingw32-make you might have to do things differently. Most of us ( Including me initially ) fall prey and download the mingw32-make and try to run our project with it. This leads to some errors during execution ( Since project Makefile's usually has native Unix/Linux commands ). For simple command execution they work the same, but for more complicated actions the commands will have to differ.

So if you are here after installing any version of make before, I'd strongly recommend you to uninstall/delete it.

INSTALLATION

  • Step 1 : Install Msys2 - msys2.org or direct install from here
  • Step 2 : Follow installation instructions. Follow till Step No 7. ( I would recommend you install with all the default options. )
  • Step 3 : Add 'your_msys64_path\usr\bin' to your path. (Eg - C:\msys64\usr\bin) .
  • Step 4 : Add 'your_msys64_path\mingw64\bin' to your path. (Eg - C:\msys64\mingw64\bin) [To be able to run gcc].

Thats it ! You are good to go ! Make sure to close the terminals that are already open. Restart the terminal and 'make' should work like a charm on your Windows system !

References :