How to Install MinGW C/C++ Compiler in Windows 11

If you’re learning C or C++ programming, one of the first things you’ll need is a reliable compiler to run your code. On Windows 11, MinGW (Minimalist GNU for Windows) is one of the most popular and lightweight compilers you can install. It provides the GCC (GNU Compiler Collection) toolchain, allowing you to compile and run C and C++ programs right from the Windows terminal or Visual Studio Code.

However, installing and configuring MinGW correctly can be tricky if you’re doing it for the first time. So, in this step-by-step guide, we’ll walk you through how to install the MinGW C/C++ compiler on Windows 11, configure the system environment variables, and verify that everything works properly.

What Is MinGW and Why Do You Need It?

MinGW (short for Minimalist GNU for Windows) is an open-source development environment that brings the GNU Compiler Collection (GCC) — which includes compilers for C, C++, Fortran, and others — to Windows systems.

In simpler terms, if you’ve ever written C or C++ code, MinGW allows your computer to understand and execute it. It’s commonly used because it:

  • Works seamlessly with IDEs like Visual Studio Code and Code::Blocks
  • Supports both C and C++ languages
  • Offers lightweight installation with only necessary components
  • Doesn’t require a separate runtime environment (unlike Cygwin)

Now that you know what it is, let’s move on to installing it on Windows 11.

How to Install MinGW C/C++ Compiler on Windows 11

Below are the detailed steps to install MinGW, set it up properly, and confirm that it’s working as expected on your system.

1. Download MinGW Installer

  1. Open your web browser and visit the official MinGW SourceForge page: https://sourceforge.net/projects/mingw
  2. Click the Download button to get the mingw-get-setup.exe installer.
  3. Once the download is complete, double-click the file to launch the MinGW Installation Manager setup.

2. Install the Required Compiler Packages

  1. In the setup window, click Install and choose the installation directory (by default, it’s C:\MinGW — you can keep this).
  2. Once the Installation Manager opens, look for the package list. From the left sidebar, click on Basic Setup.
  3. You’ll see several packages. Right-click on the following ones and select Mark for Installation:
    • mingw32-base – for the GCC compiler
    • mingw32-gcc-g++ – for the C++ compiler
    • msys-base – provides terminal tools (optional but recommended)
  4. After selecting the packages, click on Installation (top-left menu) → Apply ChangesApply.
  5. Wait for the download and installation process to complete. This may take a few minutes depending on your internet connection.

3. Add MinGW to System Environment Variables

Once the installation is done, you’ll need to add MinGW to your PATH environment variable so that you can run gcc or g++ from any directory in the Command Prompt or PowerShell.

Follow these steps:

  1. Press Windows + S, type Environment Variables, and select Edit the system environment variables.
  2. In the System Properties window, click on Environment Variables.
  3. Under the “System variables” section, find and select Path, then click Edit.
  4. Click New, then paste the following path (or your custom installation path if you changed it): C:\MinGW\bin
  5. Click OK on all open windows to save the changes.

4. Verify the Installation

Now, it’s time to check whether MinGW was installed successfully.

  1. Open Command Prompt or PowerShell.
  2. Type the following command and hit Enter: gcc --version If MinGW is installed correctly, you should see the GCC version details on your screen. Example output: gcc (MinGW.org GCC-6.3.0-1) 6.3.0 Copyright (C) 2016 Free Software Foundation, Inc.
  3. You can also test the C++ compiler by running: g++ --version

If both commands return version information instead of an error, congratulations — your MinGW setup is working perfectly!

5. (Optional) Test MinGW with a Sample C or C++ Program

Let’s make sure the compiler is working by running a simple “Hello World” program.

1. Create a new file named test.c (for C) or test.cpp (for C++) and add the following code: C Program Example:

#include <stdio.h> 
int main() {printf("Hello, World!"); 
return 0; }

C++ Program Example:

#include <iostream> 
using namespace std; 
int main() { 
cout << "Hello, World!" << endl; 
return 0; 
}

2. Save the file in any folder (e.g., C:\Users\YourName\Desktop).

3. Open Command Prompt and navigate to that folder using: cd Desktop

4. Compile the file using: gcc test.c -o test or g++ test.cpp -o test

5. Finally, run the program: test

If you see “Hello, World!” printed on the screen — your compiler is up and running perfectly.

Wrapping Up

And that’s it! You’ve successfully learned how to install the MinGW C/C++ compiler on Windows 11. With MinGW configured, you can now compile and run your C or C++ programs directly from the terminal or inside an IDE like Visual Studio Code.

Whether you’re a beginner learning programming or a developer setting up a new environment, MinGW is one of the most straightforward and efficient compilers to get started with.

Posted by Arpita

With a background in Computer Science, she is passionate about sharing practical programming tips and tech know-how. From writing clean code to solving everyday tech problems, she breaks down complex topics into approachable guides that help others learn and grow.