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.
- Press Win + R together to open the Run window.
- Type cmd and press Enter to bring up the Command Prompt.
- Type the command
Winget install GnuWin32.make
and press Enter.
- Type Y to agree to source agreements.
- After installation, press Win + R again.
- Type
systempropertiesadvanced
and press Enter.
- Select Environment Variables under the Advanced tab.
- Under System variables, select New.
- Under the variable name, enter make.
- Under Variable value, enter
C:\Program Files(x86)\GnuWin32\bin\make.exe
. - Or, select Browse File and go to the above location.
- 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.
- Press Win + X keys together to open the Power menu.
- Select Windows Powershell(Admin).
- 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.
- Downloads and installs chocolatey as available from their official source.
- Type
choco
to verify if the installation worked.
- Now, type the command ‘
choco install make
‘ to install Make.
- 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.
- Press Win + X keys together to open the Power menu.
- Select Windows Powershell(Admin).
- Type the command ‘
Wsl --install
‘ and press Enter.
- Restart your PC.
- Go to the Start Menu and type Ubuntu to bring up the Ubuntu command line.
- Type the following ‘
Sudo apt install gcc build-essential make -y
‘ and press Enter.
- 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.
- Download the latest version of MinGW-get-setup.exe.
- Install MinGW by opening the setup file.
- Turn off installing graphical interface.
- Select Continue to start installation.
- Go to the installation directory and locate the bin folder.
- Make sure MinGW-get.exe exists.
- Press Win + R together to open the Run window.
- Type
systempropertiesadvanced
and press Enter. - Select Environment Variables under the Advanced tab.
- Under System variables, double-click on Path.
- Select New.
- Type the location of MinGW-get.exe. E.g.
C:\MinGW\bin
- Select OK.
- Press Win + X together to open the Power menu.
- Select Windows Powershell.
- Type the command ‘
Mingw-get install mingw32-make
‘ and press Enter.
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.
- Go to the location of the source code.
- Do a right-click and select Text document under New.
- Give it the name Makefile.
- Assuming the source code is source.c, paste the following lines in your makefile as given in this tutorial.
- Finally, open Command Prompt and go to the source code location using the cmd command.
- Type make and press Enter.
- You can now share and open the output file as an application.
- 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.
GNU Make for Windows (x86_64)
This repository is meant to provide an easy way to cross-compile GNU Make for Windows as trusted binaries of the most recent version were previously hard to find.
Using the Binaries
Head to the Releases page to download make.exe
together with any required .dll
files as a .zip
-file. Create a new directory, e.g. C:\GNUMake
where you can later extract the archive to. Now unpack the downloaded archive to this directory using the Windows explorer (or another file compression utility of your choice).
To make sure that you can invoke the make
command from a shell, add the directory you created previously to your PATH environment variable first.
You may have to restart your shell (or your system just to make sure) afterwards. You can then test whether make
is installed properly by entering make --version
into a shell.
The output should look similar to this:
GNU Make 4.4 Built for x86_64-w64-mingw32 Copyright (C) 1988-2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://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.
Building Locally
This part was tested on Fedora 37 only so far, so you may have to adapt the package names or install additional ones.
-
Install mingw64-gcc
-
Clone this repository
-
Download the
tar.gz
file of the GNU Make releaseFetch the tarball you would like to build from the project website or one of the mirrors listed there.
-
(Optional, but recommended): Verify the integrity of the downloaded file
Download the corresponding by downloading the corresponding
tar.gz.sig
file as well.
Import the public key of the developer who signed the file. As of writing, the latest key for signing the releases was announced here. You can now verify the signature by runninggpg --verify make-*.tar.gz.sig
. -
(Optional): Update the
build_version.sha256sum
fileIf you would like to build a version of GNU Make that differs from the latest one used here, you have to update the
build_version.tar.gz
file because it determines the filename and hash which the build-script uses later. To update it, run the following command (adapt to your make version number).sha256sum make-4.4.tar.gz > ./build_version.sha256sum
-
Compile
Open a shell and run the
cross_build_w64.sh
script included in this repository.
If everything went well, you can find make.exe
and its dependent .dll
files in the make-<your version>/dist
directory.
Known Limitations
- The built binaries come without the Guile Integration of GNU Make.
- Currently the builds are not reproducible. I’m still investigating what causes the differences. If you have an idea, how to adapt this repo to produce reproducible artifacts, PRs are welcome 😄
- Limited Testing: I’m only using a tiny subset of Make’s functionalities. If you encounter issues related to how these binaries are built, feel free to create an issue. Please note however that I’m not a maintainer of GNU Make itself, I only have built this repository.
Я следую инструкциям человека, репозиторий которого я клонировал на свою машину. Я хочу просто: иметь возможность использовать команду make
как часть настройки среды кода. Но я использую Windows и поискал в Интернете только файл make.exe для загрузки, файл make-4.1.tar.gz
для загрузки (я не знаю, что с ним делать дальше) и кое-что о загрузке MinGW (для GNU; но после его установки я не нашел упоминания о «make»).
Мне не нужен компилятор GNU или что-то подобное; Я хочу использовать только make в Windows. Скажите, пожалуйста, что мне нужно сделать для этого?
Заранее спасибо!
person
Hashem Elezabi
schedule
20.08.2015
source
источник
Ответы (10)
make
— это команда GNU, поэтому единственный способ получить ее в Windows — это установить версию Windows, подобную той, которую предоставляет GNUWin32. В любом случае, есть несколько способов получить это:
-
Самый простой выбор — использовать Chocolatey. Сначала вам нужно установить этот менеджер пакетов. После установки вам просто необходимо установить
make
(вам может потребоваться запустить его в командной строке с повышенными правами / администратором):choco install make
-
Другой рекомендуемый вариант — установка подсистемы Windows для Linux (WSL / WSL2), поэтому у вас будет выбранный вами дистрибутив Linux, встроенный в Windows 10, где вы сможете установить
make
,gcc
и все инструменты, необходимые для создания программ C. -
Для более старых версий Windows (MS Windows 2000 / XP / 2003 / Vista / 2008/7 с msvcrt.dll) вы можете использовать GnuWin32.
Устаревшей альтернативой был MinGw, но проект кажется нужно отказаться, поэтому лучше выбрать один из предыдущих вариантов.
person
Eduardo Yáñez Parareda
schedule
20.08.2015
GNU make доступен на шоколадном языке.
-
Установите шоколад с здесь.
-
Затем
choco install make
.
Теперь вы сможете использовать Make в Windows.
Я пробовал использовать его в MinGW, но он должен работать и в CMD.
person
Vasantha Ganesh
schedule
08.01.2019
Принятый ответ в целом является плохой идеей, потому что созданный вручную make.exe
останется и потенциально может вызвать неожиданные проблемы. На самом деле это нарушает работу RubyInstaller: https://github.com/oneclick/rubyinstaller2/issues/105
Альтернативой является установка make через Chocolatey (как указано @Vasantha Ganesh K)
Другой альтернативой является установка MSYS2 из Chocolatey и использование make
из C:\tools\msys64\usr\bin
. Если make
не устанавливается автоматически вместе с MSYS2, вам необходимо установить его вручную через pacman -S make
(как указано @Thad Guidry и @Luke).
person
thisismydesign
schedule
25.03.2018
Если вы используете Windows 10, она встроена в функцию подсистемы Linux. Просто запустите командную строку Bash (нажмите клавишу Windows, затем введите bash
и выберите «Bash в Ubuntu в Windows»), cd
перейдите в каталог, который вы хотите создать, и введите make
.
FWIW, диски Windows находятся в /mnt
, например C:\
диск — это /mnt/c
в Bash.
Если Bash недоступен в меню «Пуск», вот инструкции по включению этой функции Windows (только для 64-разрядной версии Windows):
https://docs.microsoft.com/en-us/windows/wsl/install-win10
person
Stefan
schedule
10.01.2019
Загрузите make.exe с их официального сайта GnuWin32
-
В сеансе загрузки нажмите Полный пакет, кроме источников.
-
Следуйте инструкциям по установке.
-
По завершении добавьте
<installation directory>/bin/
в переменную PATH.
Теперь вы сможете использовать make в cmd.
person
Manu S Pillai
schedule
04.12.2018
Другой альтернативой является то, что если вы уже установили minGW и добавили папку bin в переменную среды Path, вы можете использовать «mingw32-make» вместо «make».
Вы также можете создать символическую ссылку от «make» к «mingw32-make» или скопировать и изменить имя файла. Я бы не рекомендовал эти варианты раньше, они будут работать, пока вы не внесете изменения в minGW.
person
Persike
schedule
23.07.2019
Могу предложить пошаговый подход.
- Посетите GNUwin.
- Загрузите программу установки
- Следуйте инструкциям и установите GNUWin. Обратите внимание на каталог, в который устанавливается ваше приложение. (Вам понадобится позже1)
- Следуйте эти инструкции и добавьте make в переменные среды. Как я уже говорил вам раньше, пришло время узнать, где было установлено ваше приложение. К вашему сведению: каталог по умолчанию —
C:\Program Files (x86)\GnuWin32\
. - Теперь обновите PATH, включив в него каталог bin только что установленной программы. Типичный пример того, что можно добавить к пути:
...;C:\Program Files (x86)\GnuWin32\bin
person
Jaguarfi
schedule
10.04.2020
Одно из решений, которое может оказаться полезным, если вы хотите использовать эмулятор командной строки cmder. Вы можете установить установщик пакетов по отдельности. Сначала мы устанавливаем по очереди в командной строке Windows, используя следующую строку:
@"%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
После установки chocolatey можно использовать команду choco для установки make. После установки вам нужно будет добавить псевдоним в /cmder/config/user_aliases.cmd. Следует добавить следующую строку:
make="path_to_chocolatey\chocolatey\bin\make.exe" $*
После этого Make будет работать в среде cmder.
person
MATTHEW SILVEUS
schedule
22.04.2020
-
Установить npm
-
установить узел
-
Установить Make
node install make up node install make
-
Если вышеуказанные команды отображают какую-либо ошибку, установите Chocolatey (choco)
-
Откройте cmd и скопируйте и вставьте следующую команду (команда скопирована из шоколадного 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"
person
dinesh kusuma
schedule
23.09.2020
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 a popular build automation tool for software projects. It is widely used on Unix and Linux systems, but can also be used on Windows. In this guide, you’ll learn how to install and use «make» in Windows. The installation process is slightly different than on Unix-based systems, but the usage is the same. Here are a few methods to install «make» on Windows:
Method 1: Use Windows Subsystem for Linux (WSL)
To install and use «make» in Windows using Windows Subsystem for Linux (WSL), follow these steps:
-
Install WSL on your Windows machine. You can do this by following the instructions on the Microsoft website.
-
Once WSL is installed, open the Ubuntu terminal and update the package list by running the following command:
-
Install «make» by running the following command:
sudo apt-get install make
-
Verify that «make» is installed by running the following command:
This should display the version of «make» installed on your system.
-
To use «make» on your Windows machine, navigate to the directory where your makefile is located using the Ubuntu terminal.
-
Once you are in the directory, run the following command to execute your makefile:
This will build your project according to the instructions in your makefile.
-
You can also specify a specific target in your makefile by running the following command:
This will build only the specified target in your makefile.
That’s it! You can now use «make» on your Windows machine using WSL.
Method 2: Download and Install GnuWin32
Here are the steps to install and use «make» in Windows with GnuWin32:
- Download GnuWin32 from https://sourceforge.net/projects/gnuwin32/files/make/3.81/make-3.81.exe/download
- Run the installer and follow the instructions to install GnuWin32 to your desired location.
- Once installed, add the GnuWin32 bin directory to your system’s PATH environment variable. For example, if you installed GnuWin32 to
C:\Program Files (x86)\GnuWin32
, addC:\Program Files (x86)\GnuWin32\bin
to the PATH variable. - Open a command prompt and type
make
to verify that it is installed and working properly.
Here are some examples of how to use «make» with GnuWin32:
Simple makefile example:
all:
echo "Hello, world!"
This makefile will simply output «Hello, world!» when you run make
.
Compiling a C program:
CC=gcc
CFLAGS=-Wall -O2
hello.exe: hello.c
$(CC) $(CFLAGS) -o hello.exe hello.c
This makefile will compile hello.c
using the gcc
compiler with the -Wall
and -O2
flags, and output an executable file called hello.exe
.
Cleaning up object files:
CC=gcc
CFLAGS=-Wall -O2
hello.exe: hello.o
$(CC) $(CFLAGS) -o hello.exe hello.o
hello.o: hello.c
$(CC) $(CFLAGS) -c -o hello.o hello.c
clean:
rm -f hello.o hello.exe
This makefile will compile hello.c
into an object file hello.o
, and then link it into an executable hello.exe
. The clean
target will remove the object file and executable.
These examples should give you a good starting point for using «make» with GnuWin32 on Windows.
Method 3: Use Cygwin
Step 1: Install Cygwin
First, download the Cygwin installer from the official website: https://cygwin.com/install.html
Run the installer and follow the instructions to install Cygwin. Make sure to select the «make» package from the list of available packages during the installation process.
Step 2: Set up Environment Variables
After installing Cygwin, you need to set up your environment variables to use «make» from the command line.
-
Open the Control Panel and go to System and Security > System > Advanced system settings.
-
Click on the «Environment Variables» button.
-
Under «System variables», click on the «New» button and add the following variables:
-
Variable name: CYGWIN_HOME
Variable value: C:\cygwin64 (or the path where you installed Cygwin) -
Variable name: PATH
Variable value: %CYGWIN_HOME%\bin;%CYGWIN_HOME%\sbin;%PATH%
-
Step 3: Test «make»
To test if «make» is installed and working correctly, open a new command prompt and type the following command:
If «make» is installed and working correctly, you should see the version information printed in the console.
Step 4: Using «make»
To use «make», you need to create a «makefile» that specifies the rules for building your project.
Here is a simple example «makefile» that compiles a C program:
CC=gcc
CFLAGS=-Wall -Werror
all: myprogram
myprogram: main.o
$(CC) $(CFLAGS) -o myprogram main.o
main.o: main.c
$(CC) $(CFLAGS) -c main.c
clean:
rm -f *.o myprogram
To build the program, navigate to the directory containing the «makefile» and type the following command:
This will compile the program and create an executable file called «myprogram».
To clean up the project, type the following command:
This will remove all the object files and the executable file.
That’s it! You now know how to install and use «make» in Windows with Cygwin.