Setting up MinGW (Minimalist GNU for Windows) is the most popular way to compile and run C/C++ programs natively on Windows. It brings the powerful GCC (GNU Compiler Collection) tools to Windows, allowing you to use gcc for C and g++ for C++.
This complete, beginner-friendly guide walks you through downloading MinGW, configuring your system, and running your very first program. Step 1: Download and Install MinGW-w64
The modern, up-to-date version of MinGW is managed via MSYS2, which provides the latest native builds of GCC.
Go to the official MSYS2 Website or VS Code MinGW Guide to download the installer.
Run the installer and follow the prompt steps (installing to the default path C:\msys64 is highly recommended).
Once finished, check the box to Run MSYS2 now. A terminal window will open.
Type the following command and press Enter to install the full MinGW toolchain:
pacman -S –needed base-devel mingw-w64-ucrt-x86_64-toolchain Use code with caution.
Press Enter to accept all default packages, then type Y to confirm the installation. Step 2: Add MinGW to System Environment Variables (PATH)
Windows does not automatically know where your new compiler lives. You must manually add it to your system paths so you can run it from any terminal. Using GCC with MinGW – Visual Studio Code
Leave a Reply