MinGW is the abbreviation of “Minimalist GNU for Windows”, which contains a lot of develop tools. Now we often use the MinGW-64 version. If we need to compile some C/C++ files, the MinGW has what we need.
However, install MinGW is a little cumbersome, the more common way is install MSYS2.
The MSYS2 is the abbreviation of “Minimal SYStem 2”. It is a “micro Linux-like develop environment”, which contains many Linux tools includes bash, ls, grep, sed, awk, find, make, git…
1.1 Why do we install MSYS2 instead of MinGW directly?
After installing the MSYS2, we get a magnificent advantage: the pacman(Package Manager).
e.g. The traditional way to install the GCC:
Step1. download the compressed file(zip or tar file…)
Step2. decompress the file.
Step3. configure the PATH
If you need to update your GCC, you need to redownload the file and cover it .
But if you use the pacman, you just need one command to finish the installation:
pacman -S mingw-w64-ucrt-x86_64-gcc
1.2 Summary
So let’s conclude the COT:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
We need to compile C/C++ files ↓ We need a C/C++ compiler ↓ MinGW-w64 provides GCC/G++ compilers for Windows ↓ We need to install a MinGW-w64 toolchain ↓ There are several ways to install MinGW-w64 ↓ The recommended way is to install MSYS2 ↓ MSYS2 provides the pacman package manager ↓ Use pacman to install the MinGW-w64 toolchain ↓ Use gcc/g++ to compile C/C++ files
After installing this, run this command to install gcc and gdb in the UCRT64 window:
1
pacman -S mingw-w64-ucrt-x86_64-gcc
1
pacman -S mingw-w64-ucrt-x86_64-gdb
Check:
1 2 3 4 5 6 7
test@ѩ▒ UCRT64 ~ $ gcc --version gcc.exe (Rev5, Built by MSYS2 project) 16.1.0 Copyright (C) 2026 Free Software Foundation, Inc. This is free software; see the sourcefor copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1 2 3 4 5 6 7 8
test@ѩ▒ UCRT64 ~ $ gdb --version GNU gdb (GDB) 17.2 Copyright (C) 2025 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
check in the git bash:
1 2 3
test@▒ѩ▒ MINGW64 ~ $ gcc --version bash: gcc: command not found
the gcc command is not found, so we need to add the PATH.
test@ѩ▒ MINGW64 ~ $ g++ --version g++.exe (Rev5, Built by MSYS2 project) 16.1.0 Copyright (C) 2026 Free Software Foundation, Inc. This is free software; see the sourcefor copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
test@ѩ▒ MINGW64 ~ $ gcc --version gcc.exe (Rev5, Built by MSYS2 project) 16.1.0 Copyright (C) 2026 Free Software Foundation, Inc. This is free software; see the sourcefor copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
test@ѩ▒ MINGW64 ~ $ gdb --version GNU gdb (GDB) 17.2 Copyright (C) 2025 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
3. Configure VS Code
3.1 Choose the default compiler for c/cpp
Open the VS Code, find the gear at the left-bottom. Click and choose the settings, then search C_Cpp.default.compilerPath. Open the setting.json, and fulfill the value: