How to Install GCC on Windows

Install GCC on Windows

The GNU Compiler Collection (GCC) is a free and great compiler system (C, C++, Fortran) that is the default on Linux and macOS. However, GCC (or another toolchain) is not included with Windows out-of-the-box and developers planning on using in Windows must install it on their own if they intend to look at or compile .c or .cpp programs locally. 

Since Windows does not come pre-packaged with developer tools, such as gcc, g++, or make, the initial learning curve for novices can be really steep. Many have had issues running into environment variables, incompatible builds, or missing dependencies. This guide aims to ease that friction by guiding you through the MinGW-w64 installation method, a stable, lightweight, and well-supported distribution of GCC built specifically for the Windows platform.

We will test all steps on Windows 11, but this process should apply gcc for Windows 10 and 8.1 as well. Also, since we avoiding emulation layer such as WSL or a complete IDE, we will narrow the development environment down to MinGW-w64. This will be only native and portable.

Why MinGW-w64 Is the Best GCC Option for Windows

MinGW-w64 is a fork of MinGW that is actively maintained and provides up to date modern versions of GCC with better 64-bit and multithreading support. It is well-suited for compiling modern C/C++ code and is fully POSIX thread compliant, abstracting developers from the underlying platform, useful for many cross-platform libraries (e.g libcurl).

MinGW-w64 is nothing like the other options. It’s a light-weight, portable, installer-free product that won’t bloat your system. If you want to build a minimal dev environment later, it works with editors (like VS Code or Sublime Text, etc.).

Installing GCC Using MinGW-w64

One of the best ways to install GCC through the MinGW-w64 project, is to learn to begin a C/C++ compiler on Windows. This section, you will learn how to access binaries from a trusted GitHub source, set up the environment variable, and check that everything works as expected without running an installer.

Download MinGW-w64

To download gcc for windows, go to the official binary releases page on GitHub:

mingw official binary releases page on GitHub

Look for the most recent stable release. Select the archive that matches your system, in most cases, users should select a 64-bit version with x86_64, posix, and seh in the file name. These settings dictate how the compiler is built to integrate with modern Windows systems and exception handling.

Download the .7z or .zip archive, and extract the file to an empty folder. In the folder you extracted, you’ll find sub folders and one of them will say mingw64/bin, or something similar, and here you’ll find gcc.exe, g++.exe, and all of the other compilers. This is your GCC binary path.

Add GCC to Windows System PATH

This method does not require an installer. Once the archive is extracted, the toolchain is ready to use. To be able to run gcc in any terminal window without having to navigate to the gcc executable folder each time, you will need to add the binary folder to the system PATH environment variable. This will tell Windows where the compiler is (in the bin folder) so you do not need to reference that folder each time.

To do this, open the Start Menu, search “Environment Variables”, and select Edit the system environment variables. When the System Properties window opens, click the Environment Variables button. Under System Variables, select the Path variable and click Edit. Create a new entry (as shown) and paste in the path to the bin folder you copied earlier:

adding mingw to environment variable

Click OK on all open windows to apply changes. Open a new Command Prompt window and type:

gcc --version
verifying gcc version via command prompt

If the setup is correct, it will show the installed GCC version along with build details.

Verify Installation

To test whether GCC works properly, write a simple C program. Open a text editor like Notepad and enter:

#include <stdio.h>

int main() {

    printf("GCC is working!\n");

    return 0;

}

Save the file as hello.c in a folder such as C:\gcc_test.

Open Command Prompt, navigate to the folder:

cd C:\gcc_test

Then compile the program using:

gcc hello.c -o hello.exe

Run the executable:

hello.exe

You should see:

GCC is working!

If you encounter an error like “gcc is not recognized,” revisit the PATH variable setup and confirm the full path to the bin directory was added correctly. If the file compiles but doesn’t run, make sure you’re not working in a protected directory or one requiring admin rights.

Once verified, GCC is fully configured on your Windows system. You’re now ready to compile C and C++ programs directly from the command line.

Common Errors and Fixes

If gcc is not recognized, double-check that the correct path was added to the system environment variables and that you opened a new Command Prompt after editing.

If you get a permissions issue, avoid saving or compiling files in system directories like C:\Windows or Program Files. Always work in folders where you have full read/write access.

If DLL-related errors appear on execution, use a build marked as “static” or ensure that required runtime libraries are present. The GitHub builds typically don’t have this problem unless they were incorrectly extracted.

Conclusion

Installing GCC on Windows can seem challenging, especially for new developers unfamiliar with environment variables or manual compiler setup. However, using the MinGW-w64 distribution simplifies the process by offering a lightweight, no-installer solution that’s easy to configure and fully compatible with modern C and C++ standards. This guide walked through downloading the correct binaries from GitHub, setting the system PATH, and compiling a test program—all using native tools without relying on WSL or third-party IDEs.

By choosing MinGW-w64, you avoid unnecessary complexity and get a portable, stable GCC environment directly on Windows. This method is ideal for students, hobbyists, and professionals alike who want a clean, efficient setup without leaving the Windows ecosystem. Once configured, you can confidently compile and run C or C++ code from the terminal, integrate with editors like VS Code, and build on this foundation for larger development projects.

Set Up GCC with Ease on UltaHost’s Windows 10 VPS for Reliable Development. Compile C/C++ applications effortlessly using MinGW-w64 on UltaHost’s high-performance Windows VPS. Enjoy full administrative access, native Windows compatibility, and fast NVMe storage—perfect for developers seeking a seamless GUI-friendly environment. With remote desktop access (RDP), reliable uptime, flexible scalability, and 24/7 expert support, UltaHost’s Windows Private Server is the ideal choice for stable and efficient GCC-based development.

FAQ

What is GCC and why do I need it on Windows?
Is MinGW-w64 better than MinGW?
Can I install GCC without an internet connection?
How do I check if GCC is installed correctly?
Do I need to install an IDE to use GCC?
Will this work on Windows 10 and 11?
Is MinGW-w64 safe to use?

Related Post

How to Create Visual Basic Script: Step-by-St...

Visual Basic Script short for VBScript is a lightweight...

How to Install Curl on Windows?

Curl stands for Client URL is a popular command-line to...

How to Check Open Ports in Windows

Imagine you're playing your favorite online game, but y...

How to Install WinAmp in Windows

Winamp, the classic media player that was populari...

How to Install Lua on Windows

Lua is a lightweight programming language that has gain...

How to Install Notepad++ on Windows 10

Notepad++ is a powerful free text editor widely used by...

Leave a Comment