Reputation: 4817
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?
Upvotes: 464
Views: 1248400
Reputation: 1928
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.
Edit: the above instructions is editted version to address all the comments below as they arise.
Upvotes: 131
Reputation: 31
To elaborate on the accepted answer's first option by using (Make for Windows) for installing make above.
The default install of GnuWin32 on Windows 11 was in Program Files (x86). I setup my environment variables PATH to point to the bin with the make.exe, but for whatever reason this location did not work.
When I moved the GnuWin32 folder to Program Files (without the "(x86)") and changed the env vars PATH accordingly, it worked as expected.
You likely need to restart your computer as it appears that the PATH vars are cached at the start of sessions.
Upvotes: 0
Reputation: 10406
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:
Directly download from Make for Windows
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
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
, gcc
and all the tools you need to build C programs.
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.
Upvotes: 636
Reputation: 973
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:
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!
Upvotes: 14
Reputation: 382
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.
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 :-)gnumake.exe
from the directoy GccRel (when compiled with gcc)make.exe
As others have noted: This manual installation might cause conflicts if you have various make versions installed by other programs as well.
Upvotes: 5
Reputation: 11
Install npm
install Node
Install Make
node install make up
node install make
If above commands displays any error then install Chocolatey(choco)
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"
Upvotes: -3
Reputation: 21
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.
Upvotes: 0
Reputation: 142
I could suggest a step by step approach.
C:\Program Files (x86)\GnuWin32\
. ...;C:\Program Files (x86)\GnuWin32\bin
Upvotes: 7
Reputation: 63
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.
Upvotes: 4
Reputation: 25172
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).
Upvotes: 28
Reputation: 766
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
Upvotes: 22
Reputation: 5110
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.
Upvotes: 324
Reputation: 949
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.
Upvotes: 17
Reputation: 608
$ pacman -S make gettext base-devel
C:\msys64\usr\bin\
to your pathUpvotes: 19