How to Install MinGW for C/C++ on Windows
Learn how to install MinGW for C/C++ on Windows. Follow our step-by-step tutorial to configure GCC and environment variables correctly.

MinGW (Minimalist GNU for Windows) is a native development environment that includes a porting of the famous C/C+ compiler (GCC). Provides freely distributed import libraries and header files, essential for creating native applications for Windows. In this practical tutorial, we will guide you through all the steps needed to successfully install and configure MinGW on your device.
How to install MinGW tools for C/C + + #
Step 1: Visit the official project page on SourceForge to download MinGW and click the Download button. The installation executable file download will begin automatically within 5 seconds.

Step 2: Double-click the newly downloaded .exe file to open the installer and click Install. The system will automatically start downloading all the preliminary configurations necessary for the operation of MinGW.
Step 3: After all basic configurations have been downloaded, click Continue. At this point, the MinGW Installation Manager interface will open, the compiler package manager.

Step 4: In the installation manager, under the Basic Setup section, right-click each essential package for programming (such as mingw32-base and mingw32-gcc-g++) and select “Mark for Installation” to mark them.

Step 5: Click the Installation menu on the top left, choose the Apply Changes option and then confirm by selecting Apply. The manager will begin to download all necessary files; the process may take 5-6 minutes depending on the connection. Once completed, click Close.

How to change environment variables for MinGW #
After completing the installation of MinGW, the next and fundamental step is to update the Windows environment variables. This will allow the system to globally recognize compiler commands.
Step 1: Open File Explorer, access your device’s Local Disk (C:) and open the MinGW folder. Inside, enter the bin-named folder and copy the entire path from the top address bar.

Step 2: Go to Control Panel, access the System and Security section and then System. Click on Advanced System Settings from the side menu and finally click on the Ambient Variables button… down.

Step 3: In the System Variables pane, search for Path entry, select it and click Edit. Add a new record by clicking New. Paste the path of the previously copied bin folder and click OK in all open windows to save.

This marks completion of the basic installation of MinGW in your operating system.
Another method to change environment variables for MinGW #
If you use more recent versions of Windows, you may prefer this alternative method.
Step 1: Open Disk C:, look for MinGW folder. Inside, access the bin folder and copy the path (usually C:\MinGW\bin).

Step 2: Click on the icon This PC, right click in an empty space and select Show other options (if present), then click Properties as indicated by the arrow.

Step 3: On the system information screen, click on the Advanced System Settings link.

Step 4: Click the Variables button at the bottom of the window.

Step 5: Now, in the bottom pane of System Variables, search and select the Path variable, then click the Edit button.

Step 6: Click on the New button and paste the previously copied path as below screenshot shown.

Now click OK in succession for steps 6, 5 and 4. Finally, close all windows open and restart your computer to apply changes.
This marks the definitive completion of the installation of MinGW in your Windows environment, making it ready for C and C++ compilation.
Last update: 06 February 2023.
Frequently Asked Questions (FAQ) about MinGW #
What is MinGW for and why is it important for C/C++ programmers? #
MinGW (Minimalist GNU for Windows) provides an essential set of open source compilers, including GCC and G++, optimized for Microsoft operating systems. It is essential because it allows developers to write and compile native applications for Windows without having to rely on proprietary C libraries.
How can I check if MinGW has been installed and configured correctly? #
To ensure proper operation, open the Command Prompt (cmd) or PowerShell on Windows and type the gcc --version or g++ --version command. If the system returns the version of the compiler installed, the installation and setting of the environment variables went well.
What packages do I need to select in the MinGW Installation Manager to start programming? #
For standard development operations in C and C++, you just need to check the mingw32-base-bin packages (which contains the basic C compiler) and mingw32-gcc-g++-bin (to support C++ languages). Other packages offer support for languages like Fortran or Ada and can be ignored if not necessary for your projects.

