Как установить gnu make windows

The chances are that besides GNU make, you’ll also need many of the coreutils. Touch, rm, cp, sed, test, tee, echo and the like. The build system might require bash features, if for nothing else, it’s popular to create temp file names from the process ID ($$$$). That won’t work without bash. You can get everything with the popular POSIX emulators for Windows:

  • Cygwin (http://www.cygwin.org/) Probably the most popular one and the most compatible with POSIX. Has some difficulties with Windows paths and it’s slow.
  • GNUWin (http://gnuwin32.sourceforge.net/) It was good and fast but now abandoned. No bash provided, but it’s possible to use it from other packages.
  • ezwinports (https://sourceforge.net/projects/ezwinports) My current favorite. Fast and works well. There is no bash provided with it, that can be a problem for some build systems. It’s possible to use make from ezwinports and bash from Cygwin or MSYS2 as a workaround.
  • MSYS 1.19 abandoned. Worked well but featured very old make (3.86 or so)
  • MSYS2 (https://www.msys2.org/) Works well, second fastest solution after ezwinports. Good quality, package manager (pacman), all tooling available. I’d recommend this one.
  • MinGW abandoned? There was usually MSYS 1.19 bundled with MinGW packages, that contained an old make.exe. Use mingw32-make.exe from the package, that’s more up to date.

Note that you might not be able to select your environment. If the build system was created for Cygwin, it might not work in other environments without modifications (The make language is the same, but escaping, path conversion are working differently, $(realpath) fails on Windows paths, DOS bat files are started as shell scripts and many similar issues). If it’s from Linux, you might need to use a real Linux or WSL.
If the compiler is running on Linux, there is no point in installing make for Windows, because you’ll have to run both make and the compiler on Linux. In the same way, if the compiler is running on Windows, WSL won’t help, because in that environment you can only execute Linux tools, not Windows executables. It’s a bit tricky!

For tech enthusiasts, Make is a very neat way of building applications. Whether you’re trying to package your app or install somebody else’s, Make makes things easier.

Make isn’t available in Windows. When downloading a Windows application we download a setup file of EXE format. There’s no telling what these setup files may contain. You may even be downloading malware with exe format.

Below we have compiled a few different approaches to installing Make in Windows.

Table of Contents

What is Make?

GNU.org tells Make is a tool that controls the generation of programs from its source files. In simple terms, the Make tool takes the source code of the application as input and produces the application as output.

Make is targeted for applications that follow the Free and Open Source Software (FOSS) principle. It was originally designed to work across Linux systems only. The source code can be modified in any way we want before we package it up for use.

Installing Make on Windows

Using Winget

Winget tool by Windows manages installation and upgrade of application packages in Windows 10 and 11. To use this tool, you need to have at least Windows 10 or later installed on your PC.

  1. Press Win + R together to open the Run window.
  2. Type cmd and press Enter to bring up the Command Prompt.
  3. Type the command Winget install GnuWin32.make and press Enter.
    run-cmd-command
  4. Type Y to agree to source agreements.
    type Y to agree cmd-command
  5. After installation, press Win + R again.
  6. Type systempropertiesadvanced and press Enter.
    run menu
  7. Select Environment Variables under the Advanced tab.
    environment-variables
  8. Under System variables, select New.
    new-options
  9. Under the variable name, enter make.
  10. Under Variable value, enter C:\Program Files(x86)\GnuWin32\bin\make.exe.
  11. Or, select Browse File and go to the above location.
    variable-value
  12. Press on OK.

Using Chocolatey

Using Chocolatey is a great way to install make if you do not meet the minimum requirements for Winget. It is a package manager and installer for the Windows platform. For anyone familiar with Ubuntu, it is the equivalent of apt command for software installation.

Since Make is not directly available in Windows, we need to install the package manager first. Then, we will use this package manager to install the make tool.

  1. Press Win + X keys together to open the Power menu.
  2. Select Windows Powershell(Admin).
  3. Type the command ‘Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))' and press Enter.
    power-shell-command
  4. Downloads and installs chocolatey as available from their official source.
  5. Type choco to verify if the installation worked.
    powershell-choco
  6. Now, type the command ‘choco install make‘ to install Make.
    install-choco-make
  7. Go to the installation directory C:\Program Files(x86)\GnuWin32\ to confirm the installation worked.

Using WSL

Using WSL or Windows Subsystem for Linux, we can install Make directly on our PC. WSL is released by Windows so this is the most preferred way of installing Make on Windows.

For WSL, we will install Ubuntu inside our Windows.

  1. Press Win + X keys together to open the Power menu.
  2. Select Windows Powershell(Admin).
  3. Type the command ‘Wsl --install‘ and press Enter.
    powershell-wsl--install
  4. Restart your PC.
  5. Go to the Start Menu and type Ubuntu to bring up the Ubuntu command line.
  6. Type the following ‘Sudo apt install gcc build-essential make -y‘ and press Enter.
    powershell-command
  7. Wait until the installation completes.

Using MinGW

MinGW is one of the older ways to install Make on Windows. MinGW is a collection of minimal GNU files for Windows. Note that using this method, you will have to type the ming32-make instead of the make command. Both do the same work except ming32-make is the MinGW version of make.

  1. Download the latest version of MinGW-get-setup.exe.
  2. Install MinGW by opening the setup file.
    install-mingw
  3. Turn off installing graphical interface.
    install--mingw2
  4. Select Continue to start installation.
    mingw-insatallation-package-setup
  5. Go to the installation directory and locate the bin folder.
  6. Make sure MinGW-get.exe exists.
    mingw-exe-file
  7. Press Win + R together to open the Run window.
  8. Type systempropertiesadvanced and press Enter.
  9. Select Environment Variables under the Advanced tab.
    environment-variables
  10. Under System variables, double-click on Path.
    mingw-path
  11. Select New.
    new
  12. Type the location of MinGW-get.exe. E.g. C:\MinGW\bin
    type-location
  13. Select OK.
  14. Press Win + X together to open the Power menu.
  15. Select Windows Powershell.
  16. Type the command ‘Mingw-get install mingw32-make‘ and press Enter.
    windows-power-shell-command

Using Make on Windows is pretty much the same as Linux or other platforms. You need to start with a makefile along with the source code of the program.

  1. Go to the location of the source code.
  2. Do a right-click and select Text document under New.
  3. Give it the name Makefile.
    makefile
  4. Assuming the source code is source.c, paste the following lines in your makefile as given in this tutorial.
    source code
  5. Finally, open Command Prompt and go to the source code location using the cmd command.
  6. Type make and press Enter.
  7. You can now share and open the output file as an application.
  8. You can also modify the source code source.c any number of times and make will compile it as application output.

If you want to learn more about using the Make command, there’s entire documentation on its usage.

The chances are that besides GNU make, you’ll also need many of the coreutils. Touch, rm, cp, sed, test, tee, echo and the like. The build system might require bash features, if for nothing else, it’s popular to create temp file names from the process ID ($$$$). That won’t work without bash. You can get everything with the popular POSIX emulators for Windows:

  • Cygwin (http://www.cygwin.org/) Probably the most popular one and the most compatible with POSIX. Has some difficulties with Windows paths and it’s slow.
  • GNUWin (http://gnuwin32.sourceforge.net/) It was good and fast but now abandoned. No bash provided, but it’s possible to use it from other packages.
  • ezwinports (https://sourceforge.net/projects/ezwinports) My current favorite. Fast and works well. There is no bash provided with it, that can be a problem for some build systems. It’s possible to use make from ezwinports and bash from Cygwin or MSYS2 as a workaround.
  • MSYS 1.19 abandoned. Worked well but featured very old make (3.86 or so)
  • MSYS2 (https://www.msys2.org/) Works well, second fastest solution after ezwinports. Good quality, package manager (pacman), all tooling available. I’d recommend this one.
  • MinGW abandoned? There was usually MSYS 1.19 bundled with MinGW packages, that contained an old make.exe. Use mingw32-make.exe from the package, that’s more up to date.

Note that you might not be able to select your environment. If the build system was created for Cygwin, it might not work in other environments without modifications (The make language is the same, but escaping, path conversion are working differently, $(realpath) fails on Windows paths, DOS bat files are started as shell scripts and many similar issues). If it’s from Linux, you might need to use a real Linux or WSL.
If the compiler is running on Linux, there is no point in installing make for Windows, because you’ll have to run both make and the compiler on Linux. In the same way, if the compiler is running on Windows, WSL won’t help, because in that environment you can only execute Linux tools, not Windows executables. It’s a bit tricky!

Make is an incredibly powerful tool for managing application compilation, testing and installation, or even setting up the development environment. It comes standard on Linux and macOS, and it is therefore widely adopted. But how can you get started with Make on Windows?

I’ve previously written about using Make for Python development, you might find it interesting.

If you are using Windows Subsystem for Linux (WSL/WSL2), then you can easily install make with the sudo apt install make command. However, if you want to have the command available natively on a normal terminal prompt then you need to install a Windows-specific version.

How to install Make on Windows?

The easiest way to configure Make is to use the Chocolatey package manager for Windows. It will handle downloading the correct executable, installing it, and making sure that the command is added to the system path.

  1. Install Chocolatey if you don’t already have it installed
  2. Open an elevated terminal (Run as administrator)
  3. Type the command choco install make, approve the installation if prompted

Next, verify that make works, and then you can start using it normally:

>> make --version
GNU Make 4.3
Built for Windows32
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Alternatively, if you’d prefer to use the new native Windows package manager you can use this winget command:

>> winget install GnuWin32.Make

This will download the installer and run it for you automatically. Make will also be added to the list of installed programs so you can uninstall it from the Add or remove programs section. You will still get the following error since the installer does not add make to the system path:

make : The term 'make' is not recognized as the name of a cmdlet, 
function, script file, or operable program...

To make it executable you need to open the Start menu and search for Edit the system environment variables. Click Environment Variables, then under System variables choose Path and click Edit. Click New and insert C:\Program Files (x86)\GnuWin32\bin, then save the changes. Open a new terminal and test that the command works.

As of writing this article the current version that gets installed with winget is 3.81, so it is older than the one from Chocolatey. You may want to take that into consideration when choosing the installation method. You can check which version would be installed with winget show GnuWin32.Make.

Using Make on Windows

From a syntax perspective there is no difference between Linux and Windows. You still need to write a Makefile and define the shell commands in tab-indented sections. However, the commands themselves need to be adjusted for the changed operating system.

Normally on a Makefile each line runs on a separate shell. If you need to run many commands from the same shell instance then they should be defined on the same line and chained together with the && operator.

.PHONY: test
test: venv
	.\venv\Scripts\activate && python -m unittest discover
	
.PHONY: venv
venv:
	python -m venv venv

The above example defines phony Make targets for setting up a Python virtual environment and running unit tests. Assuming that you have installed Python, running make test should execute successfully, running zero unit tests since it couldn’t find any.

If you need to make your Makefile support different operating systems, then you have to also detect the operating system to be able to run a different set of commands for each OS. With Windows the added difficulty is that in some cases (MSYS, MINGW) you actually need to use the Linux commands.

This answer on Stack Overflow has one solution for finding the correct environment, relying on how the system Path is delimited by semicolons ; unlike all other OSes. We can use that information to make our small example Makefile work natively on both Windows and Linux:

ACTIVATE := ./venv/bin/activate
PYTHON := python3
ifeq '$(findstring ;,$(PATH))' ';'
	ACTIVATE := .\venv\Scripts\activate
	PYTHON := python
endif

.PHONY: venv
venv:
	$(PYTHON) -m venv venv

.PHONY: test
os: venv
	$(ACTIVATE) && $(PYTHON) -m unittest discover

The command for activating the virtual environment is different on Windows compared to other OSes. Also the Python executable is named python on Windows, but on Linux you need to use python3. The conflicting commands can be defined as variables and then referenced in the targets.

Similarly, if you’re compiling C or C++ code, you need to use gcc or g++ on Linux, and cl on the Windows developer command prompt. Also the command arguments will need to be different.

Conclusion

It’s possible to use Make natively on Windows, and it’s not even that difficult. If you’re accustomed to using Bash and Linux commands then the switch to PowerShell commands might require a bit of adaptation. Definitely the biggest challenge is to write Makefiles that support different operating systems, but as we saw that can be accomplished with some tricks.

Search code, repositories, users, issues, pull requests…

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

  • Как установить jenkins на windows
  • Как установить fastboot для windows 10
  • Как установить inav configurator на windows
  • Как установить garageband для windows
  • Как установить javascript на windows 10