Set up C++ on Windows

Install MSYS2, open its UCRT64 terminal, and install the GCC package with pacman -S mingw-w64-ucrt-x86_64-gcc. It includes g++. Follow the official installation guide, then verify the installation with g++ --version. The screenshots below illustrate an older Windows installation. Use the paths and versions for your machine.

A simple example

Run a first program

  1. Start with A source file
  2. Do this Run the program
  3. Result Ready
Print a single word to check that your tools can run a program.
lesson.cpp
#include <iostream>

int main() {
    std::cout << ("Ready") << '\n';
}
Output
Ready
On the laptop: New terminal. Version check: g++ --version. Look for: A version number.
Get a school laptop ready for class

A coding club shares its Windows laptops between classes. Open a fresh terminal and run g++ --version. A version line tells the next student that the shell can find the C++ tool.