This guide will help you set up a clean and reliable environment for compiling and running C/C++ programs. It covers two approaches — a standard setup using MinGW (GCC for Windows) and an advanced setup using an open-source GitHub toolchain (to be detailed later).
A dedicated C/C++ environment allows you to:
- Compile and run code reliably across systems
- Avoid dependency or compiler version conflicts
- Use modern editors like VS Code for debugging and builds
- Reproduce consistent build results across teams or CI environments
Prerequisites
- Windows system (Windows 10 or later recommended)
- Basic familiarity with Command Prompt or PowerShell
- (Optional) VS Code for editing and debugging
- (Optional) For macOS/Linux, GCC or Clang compilers come preinstalled — skip directly to the verification step
There are two primary ways to install MinGW on Windows:
- Visit the official MinGW-w64 download page.
- Choose the following packages to install by selecting
Mark for Installationin the drop-down menu:mingw-developer-toolkitmingw32-basemingw32-gcc-g++mingw32-gcc-objcmsys-base
- Click on
Installation → Apply Changes(button at the top-left corner). - After installation completes, open the folder where you chose to install MinGW. By default, it is located at
C:/MinGW. - Open the
binfolder and copy its path. By default, it will beC:/MinGW/bin. - Search for
Edit the system environment variablesin the Windows search bar. - Under the Advanced tab, click on
Environment Variables. - In the System variables section, select
Pathand clickEdit. - Click
Newand paste the copied path (C:/MinGW/bin) into the list. Then click OK. - Congratulations! You have successfully completed the setup of your C/C++ source packages.
- Download MSYS2 from msys2.org.
- Scroll down to the Installation section and choose the installer based on your PC’s architecture (for most users, this will be the x86_64 executable file).
- Open the MSYS2 64-bit Terminal.
- Update the package database and core system by running below command, when prompted, type
yto confirm. The terminal will close automatically to apply changes:pacman -Syu - Reopen the MSYS2 MSYS terminal and run below command, to check for further updates:
pacman -Su - Close the terminal again to apply the updates.
- Open the MSYS2 MinGW 64-bit terminal and install GCC:
pacman -S mingw-w64-x86_64-gcc - Install debugging tools:
pacman -S mingw-w64-x86_64-gdb - Note: If you encounter any errors while running the installer, check your environment variable setup. Similar to the standard MinGW method, add
C:/msys64/mingw64/binto your system’s environment variables. - Congratulations! You have successfully installed the MSYS2 C/C++ packages.
- Navigate to the GitHub repository for releases by Skeeto.
- Download the
.exefile (packaged as a.7zarchive). - If you don’t have 7-Zip installed, download it from the official 7-Zip website.
- Extract the executable file using 7-Zip.
- Save the extracted w64devkit folder anywhere on your system, and use its bin directory path to access C/C++ packages.
- Congratulations! You have successfully installed the latest open-source C/C++ toolchain.
- Skeeto GitHub Repository
- 7-Zip File Extractor
- MSYS2 — Also recommended by the Visual Studio Code team
- MSYS2 YouTube Tutorial
- MinGW Source