Как установить gnu make windows

WINDOWS

GNU Make is a powerful build automation tool that automatically builds executable programs and libraries from source code. It reads a file called Makefile to determine how to build your project. In this article, we’ll explore how to install GNU Make on Windows, focusing on two primary methods.

Why Install GNU Make on Windows?

  • Automation: Effortlessly compile and manage dependencies for large projects.

  • Efficiency: Save time by automating repetitive tasks.

  • Cross-Platform Compatibility: Running GNU Make on Windows allows for greater consistency when working on cross-platform projects.

Let’s Keep It Short. There Are 2 Options (There Are More, But We’ll See Two).

Option 1: Using MinGW

MinGW (Minimalist GNU for Windows) is a popular choice for installing GNU Make along with other GNU utilities. Here’s how to do it:

Step 1: Download MinGW

  1. Visit the MinGW-w64 website.

  2. Click on the “Downloads” section.

  3. Select the installer that is compatible with your system architecture (32-bit or 64-bit).

Step 2: Install MinGW

  1. Run the downloaded installer.

  2. During installation, select “Basic Setup” and make sure to include mingw32-base and mingw32-gcc-g++. This will provide the necessary GNU commands including make.

  3. Click on “Installation” → “Apply Changes” to install the selected packages.

Step 3: Add MinGW to the System Path

To use make from any command prompt window, you need to add the MinGW bin directory to your system PATH.

  1. Right-click on “This PC” or “My Computer” and select “Properties”.

  2. Click on “Advanced system settings”.

  3. Click on the “Environment Variables” button.

  4. Under “System Variables”, find and select the Path variable then click “Edit”.

  5. Add the path to the MinGW bin directory, typically C:\MinGW\bin.

  6. Click “OK” to save changes and exit all dialogs.

Step 4: Verify Installation

Open a command prompt and type the following command:

If installed correctly, it should output the version of GNU Make.

Option 2: Using Cygwin

Cygwin provides a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.

Step 1: Download Cygwin

  1. Visit the Cygwin website.

  2. Click on the “Install Cygwin” link to download the setup executable.

Step 2: Install Cygwin

  1. Run the setup executable and follow the instructions.

  2. When prompted to choose packages, search for make in the package selection section.

  3. Under the Devel category, find make and click on “Skip” to mark it for installation.

Step 3: Complete the Installation

Continue with the installation process, allowing it to download and install all selected packages.

Step 4: Verify Installation

After Cygwin installation is complete, open the Cygwin terminal and run:

You should see the version of GNU Make displayed.

Troubleshooting Common Issues

  • Command not found: If you encounter this message, check that the environment path is set correctly and that the installation folders contain make.exe.

  • Makefile issues: If make runs but fails to find your Makefile, ensure you’re in the correct directory where the Makefile is located.

Conclusion

Installing GNU Make on Windows can enhance your development workflow, particularly for complex projects that require automation. In this article, we’ve walked through two primary options: using MinGW and Cygwin, providing you with the flexibility to choose what suits your needs best. Whether you opt for MinGW’s simplicity or Cygwin’s comprehensive environment, you’ll be well-equipped to leverage the power of GNU Make in your projects.

Now you are ready to create, manage, and automate your builds effectively on Windows. Happy coding!

Suggested Articles

WINDOWS

WINDOWS

WINDOWS

WINDOWS

WINDOWS

WINDOWS

Если вы читаете данную заметку, то скорее всего уже знаете, что такое Makefile и как с ним можно работать в своих проектах при написании программного кода.

Для запуска команд из Makefile необходима программа GNU Make. Если в Linux системах её просто установить и сразу можно с ней работать в среде разработки, то в Windows необходимо настроить окружение для корректной работы.

Если не настроить окружение Windows, то получим в терминале Visual Studio Code ошибку:

make: Имя "make" не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте правильность написания имени, а также наличие и правильность пути, после чего повторите попытку.

Установим и настроим GNU Make.

Установить GNU Make

Установить на Windows его можно несколькими способами.

Способ № 1

Запустить в PowerShell команду:

winget install GnuWin32.Make

Произойдёт скачивание и установка программы.

Способ № 2

Скачать программу на просторах интернета и установить вручную. Ссылка на сайт: https://gnuwin32.sourceforge.net/packages/make.htm (на момент написания статьи действующая).

Скачать версию 3.81 с моего сайта. Более свежей версии для Windows на момент написания статьи не видел.

Настроить GNU Make

После установки исполняемый файл программы доступен по пусти C:\Program Files (x86)\GnuWin32\bin. Убедитесь, что у вас программа установлена по данному пути. Если программа установилась по другому пути, то в настройках, которые описаны ниже, указывайте ваш путь.

Этот пусть необходимо прописать в системные переменные среды операционной системы. Для этого открыть Параметры и в строке поиска набрать Среды. Во всплывающей подсказке выбрать Изменение системных переменных среды:

Далее в свойствах системы выбираем Переменные среды:

В открывшемся окне в разделе Системные переменные ищем переменную Path и изменяем её, добавив требуемый путь:

В Visual Studio Code необходимо установить расширение Makefile Tools:

Перезапустить Visual Studio Code. Теперь можно запускать команды прописанные в Makefile вашего проекта.

Make is an incredibly powerful tool for managing application compilation, testing and installation, or even setting up the development environment. It comes standard on Linux and macOS, and it is therefore widely adopted. But how can you get started with Make on Windows?

I’ve previously written about using Make for Python development, you might find it interesting.

If you are using Windows Subsystem for Linux (WSL/WSL2), then you can easily install make with the sudo apt install make command. However, if you want to have the command available natively on a normal terminal prompt then you need to install a Windows-specific version.

How to install Make on Windows?

The easiest way to configure Make is to use the Chocolatey package manager for Windows. It will handle downloading the correct executable, installing it, and making sure that the command is added to the system path.

  1. Install Chocolatey if you don’t already have it installed
  2. Open an elevated terminal (Run as administrator)
  3. Type the command choco install make, approve the installation if prompted

Next, verify that make works, and then you can start using it normally:

>> make --version
GNU Make 4.3
Built for Windows32
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://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.

Alternatively, if you’d prefer to use the new native Windows package manager you can use this winget command:

>> winget install GnuWin32.Make

This will download the installer and run it for you automatically. Make will also be added to the list of installed programs so you can uninstall it from the Add or remove programs section. You will still get the following error since the installer does not add make to the system path:

make : The term 'make' is not recognized as the name of a cmdlet, 
function, script file, or operable program...

To make it executable you need to open the Start menu and search for Edit the system environment variables. Click Environment Variables, then under System variables choose Path and click Edit. Click New and insert C:\Program Files (x86)\GnuWin32\bin, then save the changes. Open a new terminal and test that the command works.

As of writing this article the current version that gets installed with winget is 3.81, so it is older than the one from Chocolatey. You may want to take that into consideration when choosing the installation method. You can check which version would be installed with winget show GnuWin32.Make.

Using Make on Windows

From a syntax perspective there is no difference between Linux and Windows. You still need to write a Makefile and define the shell commands in tab-indented sections. However, the commands themselves need to be adjusted for the changed operating system.

Normally on a Makefile each line runs on a separate shell. If you need to run many commands from the same shell instance then they should be defined on the same line and chained together with the && operator.

.PHONY: test
test: venv
	.\venv\Scripts\activate && python -m unittest discover
	
.PHONY: venv
venv:
	python -m venv venv

The above example defines phony Make targets for setting up a Python virtual environment and running unit tests. Assuming that you have installed Python, running make test should execute successfully, running zero unit tests since it couldn’t find any.

If you need to make your Makefile support different operating systems, then you have to also detect the operating system to be able to run a different set of commands for each OS. With Windows the added difficulty is that in some cases (MSYS, MINGW) you actually need to use the Linux commands.

This answer on Stack Overflow has one solution for finding the correct environment, relying on how the system Path is delimited by semicolons ; unlike all other OSes. We can use that information to make our small example Makefile work natively on both Windows and Linux:

ACTIVATE := ./venv/bin/activate
PYTHON := python3
ifeq '$(findstring ;,$(PATH))' ';'
	ACTIVATE := .\venv\Scripts\activate
	PYTHON := python
endif

.PHONY: venv
venv:
	$(PYTHON) -m venv venv

.PHONY: test
os: venv
	$(ACTIVATE) && $(PYTHON) -m unittest discover

The command for activating the virtual environment is different on Windows compared to other OSes. Also the Python executable is named python on Windows, but on Linux you need to use python3. The conflicting commands can be defined as variables and then referenced in the targets.

Similarly, if you’re compiling C or C++ code, you need to use gcc or g++ on Linux, and cl on the Windows developer command prompt. Also the command arguments will need to be different.

Conclusion

It’s possible to use Make natively on Windows, and it’s not even that difficult. If you’re accustomed to using Bash and Linux commands then the switch to PowerShell commands might require a bit of adaptation. Definitely the biggest challenge is to write Makefiles that support different operating systems, but as we saw that can be accomplished with some tricks.

Как запустить Make на Windows

Make — это широко используемая для автоматизации сборки проектов утилита, которую бывает проблематично установить и запустить на windows. Сегодня я поделюсь самым простым способом, который позволит вам это сделать. Использовать мы будем Chocolatey.

Chocolatey (choco) — это менеджер пакетов для Windows, который позволяет устанавливать и управлять программным обеспечением из командной строки. Вот как установить утилиту make на Windows с помощью Chocolatey:

  1. Установка Chocolatey:

  • Откройте PowerShell от имени администратора.

  • Вставьте следующую команду и нажмите Enter:

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'))

Эта команда скачает и запустит скрипт установки Chocolatey. Подтвердите выполнение команды, если будет запрошено разрешение.

  1. Установка make с помощью Chocolatey:

После установки Chocolatey выполните следующую команду в PowerShell:

choco install make

Chocolatey автоматически загрузит и установит утилиту make и все необходимые зависимости.

  1. Проверка установки:

make --version

Если установка прошла успешно, вы увидите вывод с информацией о версии make.

Далее, для использования make можно использовать обычный CMD, но, всегда в режиме администратора.

Если было полезно — подписывайтесь и ставьте лайки. Благодарю за внимание.

How to Install GNU Make on Windows 11

GNU Make is a build automation tool that is widely used in software development. Installing GNU Make on Windows 11 requires a few simple steps. This tutorial will guide you through the process step-by-step.

Step 1: Download the Binary

The first step is to download the binary file for GNU Make from the official website, http://www.gnu.org/software/make/.

  1. Navigate to the website and click on the “Download” button.
  2. Scroll down to “Binary releases” and select the appropriate file for your operating system. In this case, select “make-4.3-without-guile-w32.zip.”
  3. Click on the link to download the file.

Step 2: Extract the Binary

Once the binary file is downloaded, you will need to extract it.

  1. Navigate to the location where you downloaded the file.
  2. Right-click on the file and select “Extract All.»
  3. Choose a location to extract the file to and click “Extract.”

Step 3: Copy the Binary to a Directory

Next, you will copy the extracted files to a directory. For the purposes of this tutorial, we will use the “Program Files” directory.

  1. Open File Explorer and navigate to the directory where you extracted the files.
  2. Right-click on the “bin” folder and select «Copy.»
  3. Navigate to “C:\Program Files” and right-click on an empty space. Select «New» > «Folder» and name it “GNU Make.”
  4. Right-click on the “GNU Make” folder and select «Paste.» This will copy the “bin” folder into the “GNU Make” folder.

Step 4: Add GNU Make to the System Path

Once the binary is installed, you will need to add it to the system path.

  1. Right-click on the Windows icon in the taskbar and select “Search.»
  2. Type “Environment Variables” and select “Edit the system environment variables.”
  3. Click on “Environment Variables” at the bottom right of the “System Properties” window.
  4. Under “System Variables,” scroll down and select “Path,» then click «Edit.»
  5. Click «New» and enter “C:\Program Files\GNU Make\bin.» Click «OK» to save.
  6. Click «OK» to close the «Environment Variables» window.
  7. Click “OK” again to close the «System Properties» window.

Step 5: Verify the Installation

You can verify the installation by opening a command prompt and typing “make -v”. This will display the version of GNU Make that you have installed.

Congratulations! You have successfully installed GNU Make on Windows 11.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Не устанавливается windows 10 с флешки на ssd gpt
  • Как установить второго пользователя на компьютере windows 10
  • Как увеличить видеопамять на ноутбуке за счет оперативной памяти windows 10
  • Не является приложением win 32 windows xp
  • Windows 7 boot cmd