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

Stop Storing JWTs in LocalStorage: A 2026 Guide to MERN Auth

Resolving the “Script Execution Disabled” Error in PowerShell

Changing Workspace in Eclipse IDE: A Friendly Guide