Skip to main content

Setting Up MinGW on Windows: A Beginner’s Guide




Introduction

MinGW (Minimalist GNU for Windows) is a popular compiler for C, C++, and other languages that provides the necessary tools for compiling and running code on Windows. In this guide, I’ll walk you through the steps to install and configure MinGW on your system. Whether you’re just getting started or need to configure your environment, follow these simple steps!

Step 1: Download MinGW

First, download the MinGW zip file from the following link:

👉 Download MinGW

Once downloaded, you’ll see a file like this:

Step 2: Extract the ZIP File

Now that you’ve downloaded the ZIP file, it’s time to extract it.

  1. Right-click on the zip file.
  2. Choose Extract All.
  3. Extract the contents to a folder on your desktop or in any other location.

You should see a folder named mingw-w64-bin_x86_64-mingw_20111101_sezero.

Step 3: Move MinGW64 Folder to C: Drive

After extracting, move the mingw64 folder to your C: drive. Here’s how:

  1. Open File Explorer and go to the folder where you extracted the ZIP file.
  2. Select the mingw64 folder.
  3. Right-click and choose Cut.
  4. Navigate to This PC > C: drive.
  5. Right-click in the C: drive and choose Paste.

The mingw64 folder should now be located directly in the C: drive:

Step 4: Adding MinGW to Environment Variables

Now, we need to configure your system so that you can use MinGW from any command line. There are two ways to do this:

Option 1: Directly Add MinGW to Path

  1. Press Windows + S and type Environment Variables.
  2. Select Edit the system environment variables.
  3. In the new window, click Environment Variables.
  4. Under the System variables section, scroll down and select Path. Then click Edit.
  5. In the Edit window, click New and paste the path to the mingw/bin folder (it will look like this):
C:\mingw64\bin

6. Press OK to close all windows.

Option 2: Use a User Variable (Recommended)

Instead of adding the path directly, you can create a user variable. This makes it easier to update your MinGW setup in the future. Here’s how:

  1. Press Windows + S and search for Environment Variables.
  2. Click on Edit the system environment variables.
  3. In the new window, click Environment Variables.
  4. Under the User variables section, click New to create a new user variable.
  • In the Variable name field, type MINGW_HOME.
  • In the Variable value field, paste the path to your MinGW folder, for example:

C:\mingw64


5. Press OK to create the variable.

6. Now, under System variables, scroll down and select Path.

7. Click Edit.

8. In the Edit window, click New and add the following line: 

%MINGW_HOME%\bin

This tells the system to use the path stored in the MINGW_HOME variable and look for the bin folder inside it.

9. Press OK to save everything.

Step 5: Verify the Installation

To make sure everything is working correctly:

  1. Press Windows + R, type cmd, and press Enter.
  2. In the Command Prompt window, type gcc --version and press Enter.

If MinGW is installed correctly, you should see the version information for gcc, which indicates that the compiler is now ready to use.

Conclusion

Congratulations! 🎉 You’ve successfully installed and configured MinGW on your Windows machine. You now have the flexibility to use it for compiling C and C++ programs, either by adding it directly to the system path or by using a user variable for easier future maintenance.

If you have any questions or run into any issues, feel free to drop a comment. Happy coding!

Comments

Popular posts from this blog

SOLID Principles – Simple Explanation for Beginners

 When I started learning object-oriented programming, I often wrote code that worked—but was hard to maintain or extend later. That’s when I came across the SOLID principles. These are five simple guidelines that help us write code that is: Easy to understand Easy to maintain Easy to scale In this blog, I’ll explain each principle in a simple way so you can understand the idea clearly. What are SOLID Principles? SOLID is a set of five design principles introduced by Robert C. Martin. Each letter represents one principle: S → Single Responsibility O → Open-Closed L → Liskov Substitution I → Interface Segregation D → Dependency Inversion S — Single Responsibility Principle (SRP) A class should have only one responsibility. Simple idea A class should do only one job. If a class has multiple responsibilities: It becomes harder to manage Changes in one part can affect other parts Example thinking Instead of: One class handling user data + logging + validation Split it into: One class fo...

Single Responsibility Principle – Simple Explanation with Example

When writing code, it’s common to put multiple responsibilities inside a single file or class. It might work at first, but over time it becomes difficult to manage and update. The Single Responsibility Principle (SRP) helps solve this. It is one of the core ideas from SOLID and focuses on keeping code simple and maintainable. What is Single Responsibility Principle? The idea is simple: A class should have only one responsibility. That means: It should do one job It should have only one reason to change Why This Matters When a class does too many things: Changes become risky Bugs become harder to track Code becomes difficult to understand Keeping responsibilities separate makes your code: Cleaner Easier to maintain Easier to scale Bad Example (Multiple Responsibilities in One Class) Let’s look at a class that handles everything: class UserService { validateUser(user) { if (!user.email) { console.log...

Oops Concepts : Inheritance In Java

When I first started learning Java, inheritance felt a bit confusing. But once I understood the basic idea, it became one of the easiest and most powerful concepts in Object-Oriented Programming (OOP). In this blog, I’ll explain inheritance in very simple English, so even if you're a beginner student or aspiring developer, you can understand it easily.  What is Inheritance in Java? In simple words, inheritance means reusing code from another class. I usually think of it like this: A child inherits features from parents Similarly, a class can inherit properties and methods from another class Definition: Inheritance is a mechanism where a child class gets properties and methods from a parent class. Key Terms (Very Important) Parent Class (Superclass) → The class that provides properties Child Class (Subclass) → The class that inherits those properties How Inheritance Works in Java Java uses the keyword:           extends Basic Syntax: This means the Chil...