Set Up Your Toolchain¶
You need two things to take this course: a C++ compiler that supports C++17, and a text editor. That is all. There is no build system to learn, no framework to install, and nothing to configure.
Pick the route that matches your machine, then run the verification at the end of this page before moving on.
The only command the course uses
-std=c++17— compile as C++17, the standard this course is written in.-Wall -Wextra— turn on the useful warnings, so the compiler tells you about suspicious code before it becomes a bug.- Everything the course says about a program's behaviour assumes these flags. Using them means what you see matches what the author saw.
Route A — Windows¶
A1. WSL (recommended)¶
Windows Subsystem for Linux gives you a real Linux toolchain with one command, and it behaves identically to the instructions used throughout this course.
- Open PowerShell as Administrator and run:
- Restart when prompted. Ubuntu opens and asks for a username and password.
- Inside Ubuntu, install the compiler:
- Your course files should live on the Linux side for speed — for example in
~/oop-course. You can still open them from Windows editors; see Editor setup below.
A2. MSYS2 (native Windows toolchain, no Linux)¶
Prefer to stay entirely inside Windows? Use MSYS2.
- Install MSYS2 from the official site, https://www.msys2.org.
- Open the MSYS2 UCRT64 shell (not the plain MSYS2 shell) and run:
Close and reopen the shell if it asks you to. 3. Install the compiler:
- Add
C:\msys64\ucrt64\binto your PATH environment variable, sog++works from any terminal — including PowerShell and the VS Code terminal. - Close and reopen every terminal window afterwards.
A3. Single-folder compiler bundles¶
If you want neither WSL nor a package manager, standalone bundles such as
w64devkit or the MinGW-w64 builds from WinLibs give you g++ in one
folder. Unzip it, add its bin directory to PATH, and you are done.
A4. Visual Studio (MSVC) — an alternative, not the course default¶
Microsoft's compiler works perfectly well, but its command line differs from the one used in this course. If you use it, the equivalent build is:
Keep the standard flag /std:c++17; without it, older Visual Studio versions
default to an older C++ standard and some course examples will not compile.
One toolchain, not several
Mixing compilers is the most common cause of confusing errors. Pick one route — WSL or MSYS2 or MSVC — and stay with it for the whole course.
Route B — Linux¶
Use your distribution's package manager. The package that contains g++ along
with the other basic build tools is build-essential on Debian and Ubuntu:
Other distributions:
| Distribution | Command |
|---|---|
| Fedora / RHEL | sudo dnf install -y gcc-c++ |
| Arch / Manjaro | sudo pacman -S --needed gcc |
| openSUSE | sudo zypper install -y gcc-c++ |
| Alpine | sudo apk add build-base |
Route C — macOS¶
Apple's command-line developer tools include Clang, which compiles C++17 fine:
On macOS, g++ is Clang
macOS does not ship GNU g++. The g++ command is a small alias that calls
Apple's Clang instead. That is fine — the course's compile command works
unchanged — but do not be surprised when g++ --version reports an
Apple clang version rather than a GCC version.
If you specifically want GNU GCC (some compiler messages differ), install it
with Homebrew: brew install gcc, then use g++-14 or
whichever version it reports.
Route D — No installation at all (online compilers)¶
You can complete most of the modules using only a browser. These sites compile and run C++:
| Site | Notes |
|---|---|
| Compiler Explorer — https://godbolt.org | The best choice for understanding code: it shows the generated assembly next to your source. Set the compiler to a recent GCC or Clang and the standard to C++17. |
| Wandbox — https://wandbox.org | Clean, fast, supports many compiler versions. |
| OnlineGDB — https://www.onlinegdb.com/online_c++_compiler | Includes a debugger you can step through. |
| Programiz — https://www.programiz.com/cpp-programming/online-compiler | Beginner-friendly interface. |
Important limitations. Online compilers:
- usually do not let you choose an older or newer standard cleanly, so make sure C++17 is selected;
- often do not support file input/output that persists, which matters from Module 16 onwards;
- cannot use sanitizers, which the course uses to demonstrate memory bugs in Modules 10 and 11.
Use an online compiler when you are stuck on a machine without a toolchain, but install a local compiler before the labs that involve files or memory.
Editor setup¶
Any editor works — even Notepad will compile the course's examples. For a
comfortable experience without a heavy IDE, VS Code with the official
C/C++ extension is a good default: it gives you syntax highlighting, inline
compiler messages, and F5 to build and run.
To make VS Code use exactly the course's compile command, create
.vscode/tasks.json in your own project folder (not in this repository) with:
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile (course flags)",
"type": "shell",
"command": "g++",
"args": ["-std=c++17", "-Wall", "-Wextra", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"],
"group": { "kind": "build", "isDefault": true },
"problemMatcher": ["$gcc"]
}
]
}
On Windows with MSYS2, if your editor cannot find g++, give the full path in
"command", for example C:\\msys64\\ucrt64\\bin\\g++.exe.
Where to keep your own files
Do not work inside the repository's examples/ folder — you would end up
editing the course's reference copies. Create your own folder, for example
~/cpp-practice/, or use the scratch/ folder at the repository root, which
is already excluded from version control.
Verify your setup¶
Run these three commands. All three must succeed before you continue.
You should see a version banner. If it says command not found on Linux/macOS,
or is not recognized on Windows, your PATH is not set — go back to your
route above.
Type the following, then press Ctrl+D (Linux/macOS) to end input:
Expected output:
On Windows, replace /tmp/check with check.exe and run check.exe.
Then confirm your editor can save a .cpp file with LF line endings — if you
cloned the repository, its .editorconfig sets this automatically in most editors.
CRLF line endings are harmless to the compiler, but they make your file differ from
every other file in the course for no reason, and they produce noisy diffs the moment
you keep your own work in version control.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
g++: command not found (Linux/macOS) |
Compiler not installed, or not on PATH |
Install it via your package manager; reopen the terminal |
'g++' is not recognized... (Windows) |
PATH does not include the compiler's bin folder |
Add it, then reopen the terminal (changes to PATH do not affect open windows) |
unrecognized command line option '-std=c++17' |
The compiler is too old to understand the C++17 flag | Install a newer GCC. GCC 9 or newer is the practical recommendation for this course |
fatal error: iostream: No such file or directory |
You are compiling a C++ file with the C compiler | Use g++, not gcc |
permission denied: ./hello |
Missing execute permission | chmod +x ./hello |
cannot execute binary file |
You are running a file built for another platform | Rebuild with your own compiler |
| Command runs but nothing happens | On Windows you may need hello.exe |
Run hello.exe, or ./hello.exe in Git Bash |
Build succeeds, then Segmentation fault |
A runtime bug, not a setup problem | This is exactly what Modules 10 and 11 are about — carry on |
Next: Your First Program