Build a C Environment on Windows with MSYS2 (UCRT64)
If you want a clean C/C++ toolchain on Windows, MSYS2 is still one of the best choices.
This guide sets it up in UCRT64 and builds a minimal CMake project.
1) Install MSYS2
Download and install MSYS2 from the official website.
Then open MSYS2 UCRT64 terminal.
2) Update package database
First run:
1 | pacman -Syu |
If terminal asks to restart, close it and open MSYS2 UCRT64 again, then run:
1 | pacman -Syu |
3) Install build tools
1 | pacman -S --needed \ |
Check versions:
1 | gcc --version |
4) Create a minimal CMake project
Folder:
1 | hello-c/ |
src/main.c:
1 |
|
CMakeLists.txt:
1 | cmake_minimum_required(VERSION 3.20) |
5) Build with Ninja
1 | cmake -S . -B build -G Ninja |
You should see:
1 | Hello from C + CMake on MSYS2 UCRT64! |
6) Build with Make (optional)
1 | cmake -S . -B build-make -G "MinGW Makefiles" |
That is the full setup.
Once this works, you can build almost any small C/C++ project on Windows without IDE lock-in.
- Title: Build a C Environment on Windows with MSYS2 (UCRT64)
- Author: Jasper
- Created at : 2026-03-06 17:35:40
- Updated at : 2026-03-06 17:35:40
- Link: https://jasperzpzhang.github.io/windows-msys2-cmake-hello-c/
- License: This work is licensed under CC BY-NC-SA 4.0.