Installing C/C++ GNU Compilers on Windows Using MinGW
Posted: Wed Jun 11, 2025 9:19 am
This page describes how to get the MinGW C/C++ compilers up and running on Windows.
The first step is to visit the following MinGW website: https://www.mingw-w64.org/
From there download and install one of the pre-built Windows packages found here: https://www.mingw-w64.org/downloads/
One of the options on that downloads page is the packages found here: https://winlibs.com/
For example, these are the steps needed to install one of the packages found on the WinLibs page.
Step 1) Downloading and installing the 64-bit version of the GCC 15.1.0 (with POSIX threads) + MinGW-w64 13.0.0 UCRT package and unzip that file to a suitable folder.
Step 2) Use the Windows Control Panel to open up the System icon and use the Environment Variables button found in the Advanced system settings link to add this bin installation folder to the PATH environment variable.
More details about setting the PATH can be found here: http://www.zeusedit.com/phpBB3/viewtopic.php?f=5&t=6176
Step 3) Test the PATH settings using the Windows Start Button and run the cmd executable to bring up a command prompt.
To test the C compiler run the following command line:Running this command line should result in the following output:
To test the C++ compiler run the following command line:
Running this command line should result in the following output:
If you don't see this output for either of those commands, then the PATH has not been correctly configured, or the download and install has not worked.
If this happens, check the installation bin folder making sure it contains these executables and also make sure the bin folder has been correctly added to the PATH.
Step 4) Test the compiler by creating a simple c:\temp\test.cpp test file using the C++ code shown below:From inside the command prompt test the compiler by running the following commands:
Those commands change to the c:\temp\ folder and then run the C++ compiler to compile and link the c:\temp\test.cpp file to produce the c:\temp\test.exe executable.
Running those commands should produce the following output:Running the c:\temp\test.exe executable produced should result in this output:
The first step is to visit the following MinGW website: https://www.mingw-w64.org/
From there download and install one of the pre-built Windows packages found here: https://www.mingw-w64.org/downloads/
One of the options on that downloads page is the packages found here: https://winlibs.com/
For example, these are the steps needed to install one of the packages found on the WinLibs page.
Step 1) Downloading and installing the 64-bit version of the GCC 15.1.0 (with POSIX threads) + MinGW-w64 13.0.0 UCRT package and unzip that file to a suitable folder.
Code: Select all
c:\MinGW
Code: Select all
c:\MinGW\bin
Step 3) Test the PATH settings using the Windows Start Button and run the cmd executable to bring up a command prompt.
To test the C compiler run the following command line:
Code: Select all
gcc.exe --version
Code: Select all
gcc.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r2) 15.1.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Code: Select all
g++.exe --version
Code: Select all
g++.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r2) 15.1.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If this happens, check the installation bin folder making sure it contains these executables and also make sure the bin folder has been correctly added to the PATH.
Step 4) Test the compiler by creating a simple c:\temp\test.cpp test file using the C++ code shown below:
Code: Select all
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world..." << endl;
return 0;
}
Code: Select all
cd c:\temp\
g++.exe test.cpp -o test.exe
dir test.exe
Running those commands should produce the following output:
Code: Select all
c:\>cd c:\temp\
c:\Temp>g++.exe test.cpp -o test.exe
c:\Temp>dir test.exe
Volume in drive D is DATA
Volume Serial Number is 06EC-1105
Directory of c:\Temp
21/05/2016 02:30 PM 2,707,662 test.exe
1 File(s) 2,707,662 bytes
0 Dir(s) 1,824,970,645,504 bytes free
Code: Select all
Hello world...