logo logo

The next-generation blog, news, and magazine theme for you to start sharing your stories today!

The Blogzine

Save on Premium Membership

Get the insights report trusted by experts around the globe. Become a Member Today!

View pricing plans

New York, USA (HQ)

750 Sing Sing Rd, Horseheads, NY, 14845

Call: 469-537-2410 (Toll-free)

hello@blogzine.com

Step-by-Step Guide to Installing and Running Makefile on Windows 11

avatar
Louis Ferguson

An editor at Blogzine


  • 🕑 4 minutes read
  • 3 Views
Step-by-Step Guide to Installing and Running Makefile on Windows 11

A Makefile is a specialized file that outlines the flow of a program, including its targets and dependencies. To utilize it, we need to execute the Make command. However, this command is not preinstalled on Windows systems. In this article, we’ll explore how to install and run a Makefile on Windows.

How to Install and Run Makefile on Windows 11/10

A Makefile serves as a description file that contains instructions regarding the flow of a program, its targets, and libraries. This file includes a collection of targets and the sources upon which they rely. Additionally, the Makefile holds the necessary libraries that support the source code, and it is executed using the make command. To successfully install and run a Makefile on your computer, follow the steps outlined below.

  1. Download and install MinGW
  2. Configure the Environment Variable
  3. Install the Make command
  4. Rename mingw32-make.exe to Make
  5. Create and run the Makefile

Let’s delve into each step in detail.

1] Download and Install MinGW

MinGW Installation

MinGW is the Windows version of the GNU Compiler Collection (GCC), providing freely available import libraries and header files essential for developing native Windows applications. To use the Make command, you must first download the MinGW installation media. After downloading, run the installation media, ensuring to untick “also install support for the graphical user interface,”and follow the on-screen prompts to complete the installation. This process may take some time; once finished, click on Continue or Quit.

2] Configure the Environment Variable

Configuring Environmental Variable

After installing MinGW, you need to add the environment variable to access the Make command. First, locate the path of MinGW and add it to the environment variables. Follow these steps to copy the path of the mingw-get file:

  • Open File Explorer by pressing Win + I.
  • Navigate to the location where you installed MinGW. If you left the default location unchanged, it should be C:\MinGW.
  • Open the Bin folder by double-clicking on it.
  • Copy the path of this folder, which contains mingw-get.
Adding Environmental Variable

Now that you have the folder path, follow these steps to add it to the Environmental Variable:

  1. Open the Control Panel.
  2. Search for “Environmental Variables” .
  3. Select “Edit the system environmental variable.”
  4. Click on the “Environmental Variables”button.
  5. In the System variables section, select “Path”and click “Edit.”
  6. Click “New”and paste the previously copied path.
  7. Click “OK”to save your changes.

You can now close all interfaces as you’ve successfully added the environmental variable.

3] Install the Make Command

Installing Make Command

After configuring the environmental variable, you can install the Make command. Ensure that you have followed the previous steps before proceeding. To install, open the Command Prompt as an administrator and run the following command:

mingw-get install mingw32-make

Executing this command will install all modules related to Make, but be prepared for it to take some time.

Checking MinGW Version

To verify the installation, run mingw32-make --version. This will display the version information of your MinGW installation.

4] Rename mingw32-make.exe to Make

Renaming Makefile

Using ‘mingw32-make’ every time can be cumbersome. Therefore, we can rename mingw32-make to make for easier access. To do this, follow these steps:

  1. Open File Explorer.
  2. Navigate to the directory where you installed mingw32.
  3. Double-click on the Bin folder, then rename the mingw32-make file to make.

To confirm the rename, run make --version. If the command executes without errors, the renaming was successful.

5] Create and Run the Makefile

Once the Make command is installed, you can create a Makefile. There are several methods to accomplish this, but here’s a general guide you can follow:

  • Create a new folder with your desired name or simply name it Makefile on your desktop.
  • Create a text file by right-clicking in the folder and selecting New > Text Document.
  • Open the text file and paste the following lines, remembering to insert a Tab before the second line:

firstmakefile:
echo "Getting started with Makefile";

  • To save the file, navigate to File > Save As.
  • Name the file Makefile, set Save as type to All Files, and click “OK.”
  • To run the file, open Command Prompt.
  • Change to the directory where you created the folder by using the cd command. For example, if your folder is located in C:\Users\yusuf\OneDrive\Desktop, you would use cd C:\Users\yusuf\OneDrive\Desktop.
  • List all files in the directory using the dir command.
  • Run the Makefile by executing make -f filename.

This is how you can create and run a Makefile.

What is the Command to Run a Makefile?

To execute a Makefile, you need to use the make command. If you wish to specify a particular file, include the -f option, making the command structure: make -f filename.

How Do I Install Make on Windows?

To install Make on your Windows system, start by installing MinGW, then proceed to set the environment variable path, and finally install Make. We recommend following the guide provided earlier for a seamless installation process.

Source



Leave a Reply

Your email address will not be published. Required fields are marked *