Install the ucrt64 toolchain + build tools:
pacman -S --needed \
mingw-w64-ucrt-x86_64-gcc \
mingw-w64-ucrt-x86_64-gdb \
mingw-w64-ucrt-x86_64-cmake \
mingw-w64-ucrt-x86_64-ninja
Put the compiler on Windows PATH
Add ucrt64 bin to your user PATH:
C:\msys64\ucrt64\bin
(Windows Settings → System → About → Advanced system settings → Environment Variables → User Path → New.)
Verify in a new PowerShell (or Command Prompt)
g++ --version
where g++
cmake --version
ninja --version
gdb --version
You should see the MSYS2 ucrt64 paths, e.g., C:\msys64\ucrt64\bin\g++.exe.
Install CLion
Configure CLion Toolchain
The toolchain should already be configured. To verify, you can go to
CLion → File → Settings → Build, Execution, Deployment → Toolchains
and check:
- Environment: System (or leave blank)
- C Compiler: C:\msys64\ucrt64\bin\gcc.exe
- C++ Compiler: C:\msys64\ucrt64\bin\g++.exe
- Debugger: C:\msys64\ucrt64\bin\gdb.exe
- CMake: use CLion’s bundled
- Generator: Ninja (preferred) → CLion will use ninja.exe on PATH
(If CLion offers “MinGW” as a preset, point it to C:\msys64\ucrt64 and it will resolve the rest.)
Create a “Hello C++” project
- New Project → C++ (Executable) → CMake
- Keep defaults (uses CMakeLists.txt).
- CLion creates main.cpp and a simple CMakeLists.txt.
- The code prints Hello world and a sequence of numbers.
If you want to write some code of your own, create another project and use the following, simple Hello world program:
#include <iostream>
using namespace std;
int main() {
cout << "Hello world!" << endl;
}
Build & run
Click the Build hammer icon (or Build → Build Project).
Click Run (green triangle).
You should see “Hello, World!” in the Run tool window.