1. Installing GNU Make #
Although mingw32-make.exe
comes with some MinGW packages, it may not work seamlessly as make
. For consistency, install the actual make.exe
.
1.1 Download Make #
- Official GNU Make Windows binaries: https://gnuwin32.sourceforge.net/packages/make.htm
- Alternatively, use Chocolatey or Scoop:
choco install make
or
scoop install make
1.2 Set Up Make Files #
-
Extract GNU Make to a directory like
C:\make
. -
Add this path to your system
Path
:C:\make\bin
-
Open Terminal or CMD and run:
make --version
If you see something like:
GNU Make 4.3
Then Make was installed successfully.
2. Makefile Usage (Test Example) #
Let’s test if everything works by compiling a simple C program using a Makefile.
2.1 Sample Files #
File: hello.c
#include <stdio.h>
int main() {
printf("Hello, MinGW!\n");
return 0;
}
File: Makefile
CC=gcc
CFLAGS=-Wall
all: hello.exe
hello.exe: hello.c
$(CC) $(CFLAGS) -o hello.exe hello.c
clean:
rm -f hello.exe
2.2 Run Make #
Open CMD or PowerShell, navigate to the folder:
cd C:\Users\kerim\mingw_test
make
Expected output:
gcc -Wall -o hello.exe hello.c
Run the program:
hello.exe
Expected result:
Hello, MinGW!
3. (Optional) Using MSYS2 for Easier MinGW Management #
Alternatively, you can use MSYS2, which includes MinGW-w64 and a package manager (pacman
).
3.1 Install MSYS2 #
- Official website: https://www.msys2.org/
- After installation, open the MSYS2 terminal and run:
pacman -Syu
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-make
- To run
make
with MSYS2:
mingw32-make
- To compile manually:
gcc hello.c -o hello.exe
✅ Conclusion #
You can now run Makefiles on Windows using MinGW-w64 and GNU Make! 🎯
With this guide, you have:
- ✅ Installed 64-bit GCC (MinGW-w64)
- ✅ Installed GNU Make
- ✅ Successfully tested Makefile execution