Setup on Windows
MSYS2 + MinGW-w64 g++ · ~20–30 minutes · part of Compiler Setup
1. Install MSYS2
- Go to https://www.msys2.org/ and download the installer
(
msys2-x86_64-*.exe). - Run it, keep the default install location (
C:\msys64), and finish. -
Open MSYS2 UCRT64 from the Start menu (important: UCRT64, not plain MSYS2) and update the package database:
pacman -SyuIf it asks to close the window, close and reopen MSYS2 UCRT64, then run:
pacman -Su
2. Install the compiler and tools
Still in MSYS2 UCRT64:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
Press Enter to accept the default package group. This installs g++,
gdb (a debugger), and make.
3. Add the compiler to your PATH (so PowerShell/CMD find it)
- Press Start, type “environment variables”, open “Edit the system environment variables” → Environment Variables…
- Under User variables, select Path → Edit → New
- Add exactly:
C:\msys64\ucrt64\bin - OK → OK → OK.
4. Verify
Open a new PowerShell window (PATH changes apply to new windows only):
g++ --version
You should see something like g++.exe (Rev3, Built by MSYS2 project) 14.x.x.
Any 13+ version is comfortable; ≥ 9 works for this course.
5. First compile
mkdir C:\code\cpp-course\unit-01; cd C:\code\cpp-course\unit-01
notepad hello.cpp # paste the sanity-check program, save
g++ -std=c++17 -Wall -Wextra hello.cpp -o hello
.\hello.exe
You should see the program’s output. If g++ is not recognized, re-check
step 3 (and open a fresh window). More help:
FAQ troubleshooting.
6. Editor (recommended, 5 min)
Install Visual Studio Code and the C/C++ extension (publisher: Microsoft), then follow toolchain/vs-code-tips.md for a one-keystroke build and a working debugger.
Next: verify with the course’s sanity check → then Lesson 1.