download the latest installer from the MSYS2 page
In the terminal, install the MinGW-w64 toolchain by running the following command:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
Add the path to your MinGW-w64 bin
folder to the Windows PATH
environment
C:\msys64\ucrt64\bin
C:\msys64\ucrt64\bin
C:\msys64\ucrt64\bin
References
https://code.visualstudio.com/docs/cpp/config-mingw