How to install and use "make" in Windows?
Asked Answered
C

14

417

I'm following the instructions of someone whose repository I cloned to my machine. I want to use the make command as part of setting up the code environment, but I'm using Windows. I searched online, but I could only find a make.exe file, a make-4.1.tar.gz file (I don't know what to do with it next) and instructions for how to download MinGW (for GNU; but after installing it I didn't find any mention of "make").

How do I use make in Windows without a GNU compiler or related packages?

Cam answered 20/8, 2015 at 20:15 Comment(1)
Merely installing make is unlikely to solve your problem. Many Makefiles are written for Unix-like systems and will require you to install a significant amount of additional utilities (including a supported compiler if the project involves compiled code) such as Cygwin, or simply switching to a platform like WSL if you really cannot free yourself from Windows entirely.Chihuahua
E
574

make is a GNU command so the only way you can get it on Windows is installing a Windows version like the one provided by GNUWin32. Anyway, there are several options for getting that:

  1. Directly download from Make for Windows

  2. Using Chocolatey. First you need to install this package manager. Once installed you simply need to install make (you may need to run it in an elevated/admin command prompt) :

    choco install make
    
  3. Other recommended option is installing a Windows Subsystem for Linux (WSL/WSL2), so you'll have a Linux distribution of your choice embedded in Windows 10 where you'll be able to install make, gccand all the tools you need to build C programs.

  4. For older Windows versions (MS Windows 2000 / XP / 2003 / Vista / 2008 / 7 with msvcrt.dll) you can use GnuWin32.

An outdated alternative was MinGw, but the project seems to be abandoned so it's better to go for one of the previous choices.

Equipment answered 20/8, 2015 at 20:21 Comment(18)
Thanks! I didn't know make was a GNU command. I checked the path you provided and found make.exe but in a similar path (C:\MinGW\msys\1.0\bin\make.exe). I added this to the PATH variable and it works!Cam
A simpler way would be to create a symlink: mklink C:\bin\make.exe C:\MinGW\bin\mingw32-make.exe. So in the future if you do upgrade your mingw, the link would be intact.Ambros
Just using MSYS2 I wasn't able to use mklink. MSYS2's pacman can install a make pacman -S make, which is not working correctly. Instead, mingw32-make.exe was already present in msys64/mingw64/bin. Maybe it shipped with gcc. I'm confused why it's not just called make.exe, though. I just copied it to make.exe.Thelmathem
Maybe useful to mention that Visual Studio ships its own 'make' utility, nmake, see the doc. It's usable from the VS command prompt, but you can of course add it to the path. Note however that the functionalities are quite limited compared to GNU make, and the documentation is almost nonexistent...Sumbawa
WSL operates in an entirely different file system than say git bash right?Kegan
@Kegan kind of, but you can access your "Windows" folders from both of them. Git bash with /c, WSL with /mnt/c.Melancholy
Is this outdated? I installed MinGW but don't have 'mingw32-make.exe', only 'mingw-get.exe'Hardwick
@dutytrash then probably you need to download mingw32-make additional utility, as it's explained in the HowTo of MinGW page, have a look here: mingw.org/wiki/InstallationHOWTOforMinGWMelancholy
"Make is a GNU command"... sorta, but NOT EXACTLY. The original Make many decades ago was a Unix tool. Then GNU cloned it. Then GNU enhanced it _extensively, so much so that they had to abandon backward compatibility. The GNU version is so much better that very few use the original Unix version any more and it has largely disappeared. Many Linux systems contain both the original Make (called 'make') and the GNU version Make (called 'gmake').Trig
If you're a Chocolatey user, and if not why aren't you already, option 2 is definitely the way to go. Simple and fool proof. Worked with no issues.Huss
Looks mingw.org expired (RIP!). Is there a mirror somewhere?Adsorbent
@Adsorbent I don't know, but clearly the best choice is Chocolatey or just WSL/WSL2Melancholy
GnuWin32 link is wrong - also to links to chocolateyFacial
After installing make with chocolatey, can it be used in the command line or does it need to be used with powershell?Ferous
No experience with Chocolatey, but make doesn't care which shell you are using (though many Makefiles assume you have a Unix shell like Bash, and will break if you don't).Chihuahua
You could also use Cygwin's make.Sycamore
Chocolatey's make is affected by the problem described in this question. Basically, if one of your makefile recipes involves awk, you may need to run the awk command in a subshell to get it to work. Cygwin's make does not have this problem.Sycamore
Will environment variable work as usual with Chocolatey's make? I want to move scripts out of an NPM package.json, we use cross-env already but maybe it's not needed?Hardening
B
311

GNU make is available on chocolatey.

  • Install chocolatey from here.

  • Then, choco install make.

Now you will be able to use Make on windows.
I've tried using it on MinGW, but it should work on CMD as well.

Bovill answered 8/1, 2019 at 6:55 Comment(4)
Note: One may need to set the correct proxy using choco config set proxy ADDRESS:PORTDoxia
There's also scoop if you don't like how chocolaty requires an admin powershell session: github.com/lukesampson/scoop/wiki/Chocolatey-ComparisonMarshland
And how do I get configure then?Average
It seems chocolatey should not be used for commercial use chocolatey.org/terms?Turbary
T
92

On windows 10 or 11, you can run the command winget install ezwinports.make in the command line or powershell to quickly install it, restart the command line or powershell, Than you can use the command make.

There is no need to install choco anymore.

Tajo answered 27/9, 2022 at 4:8 Comment(11)
this almost works. You also need to add C:\Program Files (x86)\GnuWin32\bin to the windows PATH environment variable.Kennard
The executable file is also called make.exe and not cmake.exe, so the command is also makeSupernaturalism
make is newest on choco. choco make --version - GNU Make 4.4.1, winget make --version - GNU Make 3.81Conal
This answer should be on the top.Ermin
I had to change source from msstore: winget install --source winget GnuWin32.MakeUngraceful
For anyone confused about the env path. Just hit Win + r to open a run box, then enter sysdm.cpl to open your system properties, next navigate to the Advanced tab and you'll see the environment variables button on the bottom.Publishing
Pressing "Win + Pause" is faster. Anyway I end up with 0x8a15000f.Incomer
This is no longer available.Euphemiah
as @Euphemiah mentioned, the gnuwin32.make is no longer available. It is now ezwinports.make. Also, it is now version 4.4.1 :).... I've updated the answer to reflect this new change.Tajo
I installed it, but it doesn't show GnuWin32 in Program Files (x86)?Pasty
@JakeStBu Yes, it has changed. I've updated the answer. It looks like it adds itself to the path now so you just have to restart your command line or power shell in order to be able to use it. FYI, the bin is now installed in C:/Users/<username>/AppData/Local/Microsoft/WinGet/Packages/ where username is the account holder name.Tajo
K
28

The accepted answer is a bad idea in general because the manually created make.exe will stick around and can potentially cause unexpected problems. It actually breaks RubyInstaller: https://github.com/oneclick/rubyinstaller2/issues/105

An alternative is installing make via Chocolatey (as pointed out by @Vasantha Ganesh K)

Another alternative is installing MSYS2 from Chocolatey and using make from C:\tools\msys64\usr\bin. If make isn't installed automatically with MSYS2 you need to install it manually via pacman -S make (as pointed out by @Thad Guidry and @Luke).

Kavanaugh answered 25/3, 2018 at 22:33 Comment(2)
I installed this using Chocolatey but there is no make.exe in C:\tools\msys64\usr\bin ??Antedate
you can find pacman in that folder, after that use step 3 of @thadElver
D
22

If you're using Windows 10, it is built into the Linux subsystem feature. Just launch a Bash prompt (press the Windows key, then type bash and choose "Bash on Ubuntu on Windows"), cd to the directory you want to make and type make.

FWIW, the Windows drives are found in /mnt, e.g. C:\ drive is /mnt/c in Bash.

If Bash isn't available from your start menu, here are instructions for turning on that Windows feature (64-bit Windows only):

https://learn.microsoft.com/en-us/windows/wsl/install-win10

Duce answered 10/1, 2019 at 16:31 Comment(5)
it does not work. the shell dissapears instantlyAllen
This doesn't answer the question, because it doesn't install it In Windows. The make used here will be part of a build chain that will build Linux binaries, rather than Windows ones.Sinaloa
it may not answer the question, but solves my problem. install using $ sudo apt install makeFreeliving
Whether this is acceptable or not depends on the specific Makefile. A tooling pipeline which doesn't compile binaries for any specific platform is likely to work fine if you have the required tools; a Makefile to compile a C (or Fortran, C++, etc) project probably won't work for many, many reasons, including (as pointed out in a previous comment) the fact that if it does work, the end result is not a valid Windows binary.Chihuahua
@jayfall The apt package manager is specific to Debian Linux and derived distributions like Ubuntu. This is what WSL runs out of the box, but you can configure it to run other Linux variants which require a different package manager. For RPM-based distros like CentOS and Fedora, there's yum and dnf; for Alpine etc there's apk, Arch uses pacman etc etcChihuahua
A
18
  1. Install Msys2 http://www.msys2.org
  2. Follow installation instructions
  3. Install make with $ pacman -S make gettext base-devel
  4. Add C:\msys64\usr\bin\ to your path
Activism answered 20/8, 2015 at 20:15 Comment(0)
B
16

Download make.exe from their official site GnuWin32

  • In the Download session, click Complete package, except sources.

  • Follow the installation instructions.

  • Once finished, add the <installation directory>/bin/ to the PATH variable.

Now you will be able to use make in cmd.

Baugher answered 4/12, 2018 at 19:14 Comment(3)
Could you please help me how to set the directory to the PATH variable.Pell
@Pell Start a windows OS search (the box next to the windows button) for the word "Environment" When you see the popup for Edit the System Environment Variables in the Control Panel, Select that. System Properties --> Advanced tab app should popup. Look for the button at the bottom that says "Environment Variables"Unwitting
This does not work. I did this and I got the error that the program was build for 32 bits systems and win10 is 64 bits. Is there a make for windows 10?Allen
G
10

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!

Giese answered 28/4, 2022 at 17:24 Comment(0)
A
9

You can also install scoop, then run:

scoop install make
Aluminum answered 14/9, 2022 at 8:28 Comment(0)
A
6

I could suggest a step by step approach.

  1. Visit GNUwin
  2. Download the Setup Program
  3. Follow the instructions and install GNUWin. You should pay attention to the directory where your application is being installed. (You will need it later1)
  4. Follow these instructions and add make to your environment variables. As I told you before, now it is time to know where your application was installed. FYI: The default directory is C:\Program Files (x86)\GnuWin32\.
  5. Now, update the PATH to include the bin directory of the newly installed program. A typical example of what one might add to the path is: ...;C:\Program Files (x86)\GnuWin32\bin
Alegre answered 10/4, 2020 at 18:0 Comment(0)
S
5

I once had the same problem. But I am surprised not to find one particular solution here.

Installation from GnuWin32 or via winget are good and easy options. But I only found make 3.8.1 there. This version lacks the very important option -O, which handles the output correctly when compiling multithreaded.

choco appears to offer make 4.3, currently. So one could expect recent versions there.

But there is also the option of self compiling. And if you have to install make, which is used for compiling, this should be a valid option.

  1. head to https://www.gnu.org/software/make/ and download a version of your liking
  2. unpack the tar.gz files (use 7zip and unpack the file twice to retrieve the actual content)
  3. navigate to the created directory
  4. open command prompt in that directory
  5. run build_w32.bat gcc This will start the compilation with the gcc compiler, which you would need to install in advance. When running build_w32.bat without any option they try to use the MSVC compiler. Sidenote: I found it surprising that gnu does not use gcc as default but MSVC :-)
  6. ignore the warnings created during compilation. The result should still be fine
  7. retrieve your fresh gnumake.exe from the directoy GccRel (when compiled with gcc)
  8. put this file somewhere where you like and rename to make.exe
  9. add the location to the system variable %PATH%

As others have noted: This manual installation might cause conflicts if you have various make versions installed by other programs as well.

Sexless answered 3/12, 2021 at 4:39 Comment(0)
C
4

Another alternative is if you already installed minGW and added the bin folder the to Path environment variable, you can use "mingw32-make" instead of "make".

You can also create a symlink from "make" to "mingw32-make", or copying and changing the name of the file. I would not recommend the options before, they will work until you do changes on the minGW.

Chaechaeronea answered 23/7, 2019 at 11:39 Comment(0)
S
0

One solution that may helpful if you want to use the command line emulator cmder. You can install the package installer chocately. First we install chocately in windows command prompt using the following line:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
refreshenv

After chocolatey is installed the choco command can be used to install make. Once installed, you will need add an alias to /cmder/config/user_aliases.cmd. The following line should be added:

make="path_to_chocolatey\chocolatey\bin\make.exe" $*

Make will then operate in the cmder environment.

Seamark answered 22/4, 2020 at 6:25 Comment(0)
G
-3
  1. Install npm

  2. install Node

  3. Install Make

    node install make up
    node install make
    
  4. If above commands displays any error then install Chocolatey(choco)

  5. Open cmd and copy and paste the below command (command copied from chocolatey URL)

    @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
    
Ground answered 23/9, 2020 at 19:42 Comment(1)
There's a deleted answer from 2018 with the same proposal. It has the following comment: 'npm's make package is not the same thing as GNU Make which most build scripts expect: it's a reimplementation of make in JavaScript that is not guaranteed to be entirely compatible with traditional makefiles, this is documented in the package's page on npm: "The parser make.js uses is small and has its flaws, but for most Makefiles, make.js is able to parse them correctly." - so this is not what the OP is looking for.'Chihuahua

© 2022 - 2024 — McMap. All rights reserved.