Как запустить make в windows 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!

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.

  1. Press Win + R together to open the Run window.
  2. Type cmd and press Enter to bring up the Command Prompt.
  3. Type the command Winget install GnuWin32.make and press Enter.
    run-cmd-command
  4. Type Y to agree to source agreements.
    type Y to agree cmd-command
  5. After installation, press Win + R again.
  6. Type systempropertiesadvanced and press Enter.
    run menu
  7. Select Environment Variables under the Advanced tab.
    environment-variables
  8. Under System variables, select New.
    new-options
  9. Under the variable name, enter make.
  10. Under Variable value, enter C:\Program Files(x86)\GnuWin32\bin\make.exe.
  11. Or, select Browse File and go to the above location.
    variable-value
  12. 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.

  1. Press Win + X keys together to open the Power menu.
  2. Select Windows Powershell(Admin).
  3. 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.
    power-shell-command
  4. Downloads and installs chocolatey as available from their official source.
  5. Type choco to verify if the installation worked.
    powershell-choco
  6. Now, type the command ‘choco install make‘ to install Make.
    install-choco-make
  7. 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.

  1. Press Win + X keys together to open the Power menu.
  2. Select Windows Powershell(Admin).
  3. Type the command ‘Wsl --install‘ and press Enter.
    powershell-wsl--install
  4. Restart your PC.
  5. Go to the Start Menu and type Ubuntu to bring up the Ubuntu command line.
  6. Type the following ‘Sudo apt install gcc build-essential make -y‘ and press Enter.
    powershell-command
  7. 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.

  1. Download the latest version of MinGW-get-setup.exe.
  2. Install MinGW by opening the setup file.
    install-mingw
  3. Turn off installing graphical interface.
    install--mingw2
  4. Select Continue to start installation.
    mingw-insatallation-package-setup
  5. Go to the installation directory and locate the bin folder.
  6. Make sure MinGW-get.exe exists.
    mingw-exe-file
  7. Press Win + R together to open the Run window.
  8. Type systempropertiesadvanced and press Enter.
  9. Select Environment Variables under the Advanced tab.
    environment-variables
  10. Under System variables, double-click on Path.
    mingw-path
  11. Select New.
    new
  12. Type the location of MinGW-get.exe. E.g. C:\MinGW\bin
    type-location
  13. Select OK.
  14. Press Win + X together to open the Power menu.
  15. Select Windows Powershell.
  16. Type the command ‘Mingw-get install mingw32-make‘ and press Enter.
    windows-power-shell-command

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.

  1. Go to the location of the source code.
  2. Do a right-click and select Text document under New.
  3. Give it the name Makefile.
    makefile
  4. Assuming the source code is source.c, paste the following lines in your makefile as given in this tutorial.
    source code
  5. Finally, open Command Prompt and go to the source code location using the cmd command.
  6. Type make and press Enter.
  7. You can now share and open the output file as an application.
  8. 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.

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!

We’re Earthly. We make building software simpler and therefore faster. This article is about make and Makefiles but if you’re interested in a different approach to building software then check us out.

As the field of DevOps and build release engineering continues to grow, many new tools are being developed to help make building and releasing applications easier. One of the tools that has been in use for many years is Make, which is still heavily used by engineers today.

A Makefile is a simple text file consisting of targets, which can invoke different actions depending on what has been configured. For example, with a Makefile, you can invoke a build of your application, deploy it, or run automated tests and it can dramatically increase the efficiency of your workflow.

Initially, it was Stuart Feldman who began working on the Make utility back in 1976 at Bell Labs. However, the version of Make most commonly used today is GNU Make, which was introduced in the late 1980s.

While the tool was originally meant to run on Linux, Make’s popularity has interested those working on other operating systems as well. There are several ways to run Makefiles on Windows, and in this article you’ll be introduced to each option and learn about their strengths and weaknesses.

Using Make on Windows

windows

Before looking at the different options available, you should know why you want to run Makefiles on Windows in the first place. Or rather, if you’re working on Windows, why are you even interested in Makefiles?

Historically, the biggest reason for wanting Makefiles to run on Windows is that the developers in your organization are working on Windows. Seeing as how the de facto standard for languages like C and C++ is to use Make, it’s no wonder that Windows users want the ability to use Make as well.

As applications and infrastructure become more modern, the cloud is another reason for wanting Makefiles on Windows. Many infrastructure engineers want their applications to be run on Linux, likely led by the adoption of tools like Docker and containerization in general. Additionally, on Linux, a Makefile is the primary tool to use in many cases, especially when it comes to building native Linux applications. However, many engineers are still using Windows on their workstations, leading to the question of how to run Makefiles on Windows. Let’s dive into the possible answers.

Chocolatey

chocolatey

Linux users have been using package managers for decades, yet they’ve never gained much traction on Windows. Up until the release of winget, the concept of a package manager was never something that was natively included on Windows. Instead, Rob Reynolds started working on an independent package manager back in 2011 that would come to be known as Chocolatey. Chocolatey is now widely used on Windows to install packages, and you can use it to install make as well.

To do so, run the following command in an Administrative PowerShell window:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

You can find the newest installation instructions at any time on the Chocolatey website.

Once Chocolatey is installed, you may have to close down the PowerShell window and open it back up. After that, run the following command:

Once the script is done running, make will be installed. You may need to restart the PowerShell window again, but at this point you are ready to use Makefiles on Windows.

Chocolatey will likely be the most popular option for those who want to stick to a pure Windows installation. It’s easy to install, easy to use, and you don’t need to jump through any hoops or workarounds to get it working.

At this point, you can use make just like you otherwise would, and you can test it by running make -v.

Cygwin

Historically, one of the most popular ways of running any type of Linux functionality on Windows has been to use Cygwin. Cygwin aims to give a Linux feeling to Windows by holding a large collection of GNU and open source tools. It’s important to note that this does not mean it will give you native Linux functionality. However, it does allow you to use Linux tools on Windows. There’s a big difference between the two; for instance, Cygwin does not have access to Unix functionality like signals, PTYs, and so on. It’s a great tool for when you want to use familiar Linux commands but still want them to be run on Windows.

To use Cygwin for Makefiles, start by downloading and installing Cygwin. During the installation, you’ll see a window popping up asking you what packages you want to install. In the top left corner, make sure to select Full and then search for make.

Searching for “make”

Your search will give you a list of several different packages. You want to choose the one that’s labeled just as make. Change the dropdown menu where it says Skip to the latest version.

Choosing “make”

Now you can finish the installation by clicking Next in the bottom right corner. Once the installation is done, you can open up Cygwin and verify that make has been installed by executing make --version.

NMAKE

One of the alternatives that you’ll often hear about regarding running Makefiles on Windows is NMAKE. While it is an alternative to make, note that you cannot simply take your existing Makefiles from Linux and run them using NMAKE; they have to be ported.

First of all, the compilers are different on Windows and Linux, so if you are specifying your compiler in your Makefile, you’ll have to change that to whatever is relevant on Windows. At the same time, you’ll have to change the flags that you send to the compiler, because Windows typically denotes the flags using / instead of -.

On top of that, it doesn’t recognize all the syntax that you’re used to from GNU Make, like .PHONY. Lastly, Windows obviously doesn’t recognize the commands that work on Linux, so if you have specified any Linux-specific commands in your Makefiles, you’ll also have to port them.

All in all, if your entire organization uses Windows and you simply want the typical functionality of GNU Make, then NMAKE is a viable solution. However, if you just want to quickly run your traditional Makefiles on Windows, NMAKE is not the answer.

CMake

cmake

As with NMAKE, CMake is not a direct way to run your Makefiles on Windows. Instead, CMake is a tool to generate Makefiles, at least on Linux. It works by defining a CMakeLists.txt file in the root directory of your application. Once you execute cmake, it generates the files you need to build your application, no matter what operating system you’re on.

On Linux, this means that it creates Makefiles for you to run, but on Windows it may mean that it creates a Visual Studio solution.

CMake is a great solution if you don’t care too much about running Makefiles specifically, but you want the functionality, namely the ease of use in a build process, that you can get from Makefiles.

Windows Subsystem for Linux

The Windows Subsystem for Linux (WSL) is an honorable mention. It’s cheating a bit to say that it’s a way to run Makefiles “on Windows,” as your Makefiles won’t actually be running on Windows.

If you haven’t heard of WSL before, here’s an extremely oversimplified explanation: It uses Hyper-V to create a hyper-optimized virtual machine on your computer, in which it runs Linux. Basically, you get a native Linux kernel running on your Windows computer, with a terminal that feels as if it’s part of Windows.

You should look into WSL if what you care about most is having Windows as your regular desktop environment, but you’re fine with all of your programming and development going on inside of Linux.

Conclusion

As you can see, there are a few different ways you can be successful in running Makefiles on Windows. However, you do need to be wary of the fact that it will never be a perfect solution. Every solution is in some way a workaround, and the closest you’ll get to feeling like you’re using native Makefiles while using Windows is to install something like WSL.

If you are looking for a solution to avoid the complexities of Makefile, check out Earthly. Earthly takes the best ideas from Makefile and Dockerfile, and provides understandable and repeatable build scripts, minus the head-scratching parts of the Makefile.

Я следую инструкциям человека, репозиторий которого я клонировал на свою машину. Я хочу просто: иметь возможность использовать команду 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. В любом случае, есть несколько способов получить это:

  1. Самый простой выбор — использовать Chocolatey. Сначала вам нужно установить этот менеджер пакетов. После установки вам просто необходимо установить make (вам может потребоваться запустить его в командной строке с повышенными правами / администратором):

    choco install make
    
  2. Другой рекомендуемый вариант — установка подсистемы Windows для Linux (WSL / WSL2), поэтому у вас будет выбранный вами дистрибутив Linux, встроенный в Windows 10, где вы сможете установить make, gcc и все инструменты, необходимые для создания программ C.

  3. Для более старых версий 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

Могу предложить пошаговый подход.

  1. Посетите GNUwin.
  2. Загрузите программу установки
  3. Следуйте инструкциям и установите GNUWin. Обратите внимание на каталог, в который устанавливается ваше приложение. (Вам понадобится позже1)
  4. Следуйте эти инструкции и добавьте make в переменные среды. Как я уже говорил вам раньше, пришло время узнать, где было установлено ваше приложение. К вашему сведению: каталог по умолчанию — C:\Program Files (x86)\GnuWin32\.
  5. Теперь обновите 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

  1. Установить npm

  2. установить узел

  3. Установить Make

    node install make up
    node install make
    
  4. Если вышеуказанные команды отображают какую-либо ошибку, установите Chocolatey (choco)

  5. Откройте 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

  • Как запустить mount and blade история героя на windows 10
  • Как запустить mac os на virtualbox на windows
  • Как запустить mortal kombat komplete edition на windows 10
  • Как запустить gnuradio на windows
  • Как запустить lotr the battle for middle earth на windows 10