101

I installed MinGW and MSYS, added C:\MinGW\bin to PATH but I still can't run Makefile on Windows' cmd. I would like to run cmd.exe and there type, for example, make all but my cmd says that there is no such command.

What should I do? I don't want to use MSYS shell, that's not the point. Any ideas how to use GNU Make in Windows cmd as I can do it in Ubuntu? I'm not interested in Cygwin.

16
  • 1
    You'll have to add it to PATH under environment variables in your system settings. Commented Oct 14, 2012 at 11:41
  • @slugonamission : I did it already, I wrote :)
    – yak
    Commented Oct 14, 2012 at 11:42
  • Run make.exe instead of make? Commented Oct 14, 2012 at 11:43
  • 3
    @slugonamission : I did it! I added C:\MinGW\msys\1.0\bin to PATH, and it worked! :D But still have problem, make shows me: pastie.org/private/ixaaqbq2xl3geyg0emnow
    – yak
    Commented Oct 14, 2012 at 11:54
  • 1
    In your all target, hello.exe needs to be on the same line as all to be considered as a dependency for the target. If not, becomes part of the task for all. Commented Oct 14, 2012 at 11:58

7 Answers 7

106

Explanation

Inside directory C:\MinGW\bin there is an executable file mingw32-make.exe which is the program make you are trying to run. You can use the keyword mingw32-make and run the program make since you have added the needed directory to the system path, but it is not an easy to remember keyword.


Solution

Renaming the file from mingw32-make.exe to make.exe will allow you to run program make using the keyword make.

Renaming can be done:

  1. Manually by right clicking and renaming the file.
  2. By running the command copy c:\MinGW\bin\mingw32-make.exe c:\MinGW\bin\make.exe.

Result

Now if you type make on command prompt it should output something like:

make: *** No targets specified and no makefile found.  Stop.

Which means the program make ran.

3
  • 10
    @Imray I case it's still not completely clear: the make is distributed in file mingw32-make.exe. Since the directory c:\MinGW\bin is on system path, you can either use mingw32-make as a command or copy (safer version of renaming) the mingw32-make.exe to just make.exe. Commented May 5, 2015 at 23:56
  • 1
    You pretty much should stay away from making msys or mingw a part of your environment variables for bloat reasons, but also because msys directory is local to itself. The path in msys will allow you to use make if its in mingw64's bin, however not speaking on this problem. Also not speaking on the problem, you should create a HARD link to mingw32-make.exe as make.exe, makes life easier and not have to clone the exe. Try: mklink /H C:\MinGW\bin\mingw32-make.exe C:\MinGW\bin\make.exe Commented Sep 2, 2018 at 5:26
  • Renaming a file is easy, but also easy to forget to do when an update is installed. What you could do in order to also get the make "alias" is to use doskey. Thanks to the backwards compatibility of Windows you can have a autorun.bat on your C: drive and Windows will run that each time you start a cmd prompt (just like a .bashrc in linux, but than system wide). In that autorun.bat you put the line @doskey make=mingw32-make.exe $* which tells windows to use mingw32-make.exe when you type make and the $* appends all arguments you pass to make on to mingw32-make.exe. Commented Jun 3, 2022 at 17:23
9

I'm using GNU Make from the GnuWin32 project, see http://gnuwin32.sourceforge.net/ but there haven't been any updates for a while now, so I'm not sure on this project's status.

0
6

Although this question is old, it is still asked by many who use MSYS2.

I started to use it this year to replace CygWin, and I'm getting pretty satisfied.

To install make, open the MSYS2 shell and type the following commands:

# Update the package database and core system packages
pacman -Syu
# Close shell and open again if needed

# Update again
pacman -Su

# Install make
pacman -S make

# Test it (show version)
make -v
0
5

As an alternative, if you just want to install make, you can use the chocolatey package manager to install gnu make by using

choco install make -y

This deals with any path issues that you might have.

1
  • 1
    It's best to use Powershell, running as administrator, for this one. In particular, when I tried this with Git Bash and without the -y, Chocolatey warned me about running as a normal user, then gave me a Do you want to continue?([Y]es/[N]o): N prompt, THEN failed to respond when I pressed ENTER. I had to Ctrl-C out in the end, and this resulted in another warning message. Apparently Chocolatey can't handle Ctrl-C safely.
    – AJM
    Commented May 4, 2022 at 19:00
3

You can add the application folder to your path from a command prompt using:

setx PATH "%PATH%;c:\MinGW\bin"

Note that you will probably need to open a new command window for the modified path setting to go into effect.

0

user1594322 gave a correct answer but when I tried it I ran into admin/permission problems. I was able to copy 'mingw32-make.exe' and paste it, over-ruling/by-passing admin issues and then editing the copy to 'make.exe'. On VirtualBox in a Win7 guest.

0

While make itself is available as a standalone executable (gnuwin32.sourceforge.net package make), using it in a proper development environment means using msys2.

Git 2.24 (Q4 2019) illustrates that:

See commit 4668931, commit b35304b, commit ab7d854, commit be5d88e, commit 5d65ad1, commit 030a628, commit 61d1d92, commit e4347c9, commit ed712ef, commit 5b8f9e2, commit 41616ef, commit c097b95 (04 Oct 2019), and commit dbcd970 (30 Sep 2019) by Johannes Schindelin (dscho).
(Merged by Junio C Hamano -- gitster -- in commit 6d5291b, 15 Oct 2019)

test-tool run-command: learn to run (parts of) the testsuite

Signed-off-by: Johannes Schindelin

Git for Windows jumps through hoops to provide a development environment that allows to build Git and to run its test suite.

To that end, an entire MSYS2 system, including GNU make and GCC is offered as "the Git for Windows SDK".
It does come at a price: an initial download of said SDK weighs in with several hundreds of megabytes, and the unpacked SDK occupies ~2GB of disk space.

A much more native development environment on Windows is Visual Studio. To help contributors use that environment, we already have a Makefile target vcxproj that generates a commit with project files (and other generated files), and Git for Windows' vs/master branch is continuously re-generated using that target.

The idea is to allow building Git in Visual Studio, and to run individual tests using a Portable Git.

Not the answer you're looking for? Browse other questions tagged or ask your own question.