Setup · Windows

How to install g++ on Windows (step by step)

KuaiJiZi C++ Tutor can compile in the cloud, but local compilation is faster and works offline. This guide installs a GNU C++ toolchain and makes sure the app finds it.

8 min read Windows · MinGW-w64 · g++ · PATH downloads from official sources only

Do you actually need it?

Not to start. The app's compile & run mode is Auto by default: it looks for a local compiler and falls back to a remote compile service when there is none. Install a local toolchain when you want:

  • Faster builds (no upload/download of code),
  • Offline work without any network,
  • Full control over compiler and standard version.
Only download toolchains from their official sites (msys2.org, winlibs.com). Avoid third-party “g++ installer” bundles — a compiler has full access to your files when it runs your code.

Route A — MSYS2 (recommended)

  1. Download the MSYS2 installer from msys2.org and run it (default install path C:\msys64 is fine).
  2. Open MSYS2 UCRT64 from the Start menu.
  3. Install the compiler with pacman -S mingw-w64-ucrt-x86_64-gcc.
  4. Add the compiler folder to your PATH: C:\msys64\ucrt64\bin (see the PATH section below).
  5. Open a new terminal and verify with g++ --version.

Route B — standalone MinGW-w64 build

  1. Download a current MinGW-w64 build for Windows (x86_64) from winlibs.com.
  2. Extract it to a short, space-free path, for example C:\mingw64.
  3. Add C:\mingw64\bin to PATH.
  4. Verify in a new terminal with g++ --version.

This route is a single folder with no package manager — convenient for lab images, where you can copy the same folder to every machine.

Adding the folder to PATH

  1. Press Win, type “environment variables” and open Edit the system environment variables.
  2. Click Environment Variables…
  3. Under User variables select Path → Edit… → New.
  4. Paste the compiler's bin folder (for example C:\msys64\ucrt64\bin) and confirm all dialogs.
  5. Close and reopen any terminal — existing windows keep the old PATH.

Then restart KuaiJiZi C++ Tutor: compiler detection happens at startup. Keep the mode on Auto or switch it to Local.

Verify it worked

g++ --version
where g++

The first command prints a version line (GCC 12 or newer is a good target). The second shows which g++ Windows will use — if it points somewhere unexpected, you have more than one compiler installed and PATH order decides.

Troubleshooting

“g++ is not recognized as an internal or external command”

The PATH entry did not take effect. Check that you added the bin folder (not the parent folder), that you edited the user or system PATH correctly, and that you opened a new terminal window.

The app still uses the remote service

Run where g++. If it prints nothing, the app cannot see the compiler either. If it prints a path, restart the app — detection only happens at launch — and make sure the mode is Auto or Local.

Compilation is very slow the first time

Antivirus scanning a newly installed compiler is the usual cause; subsequent builds are much faster. Excluding the toolchain folder from real-time scanning (if policy allows) also helps.

Errors about missing standard C++ features

The compiler is too old. Install a current build (GCC 12+) rather than an old package you may already have.

Should I install this on a school lab?

Not necessarily — remote compile mode keeps every machine identical with nothing to install. Install locally on teacher machines where faster offline builds matter.

Next: understand the three modes

Auto, local g++ and the remote compile service — when each one is the right choice.

Compile & run modes Start with blocks