Back home
C++17 environment

From zero to running C++.

Install one compiler, connect it to VS Code, verify C++17, and run your first program. No mystery downloads and no outdated IDE setup.

A working setup has

Compiler01 / ready
C++17 mode02 / ready
Debugger03 / ready
Editor integration04 / ready

01 / Install the toolchain

Choose exactly one path.

VS Code is an editor. The compiler and debugger must be installed separately on your operating system.

Recommended for this course

Windows 10 / 11

MSYS2 + GCC

  1. 01Download and install MSYS2 in its default C:\msys64 folder.
  2. 02Open the MSYS2 UCRT64 terminal—not the plain MSYS terminal.
  3. 03Update packages, then install the UCRT64 GCC toolchain.
  4. 04Add C:\msys64\ucrt64\bin to your user PATH and reopen the terminal.
pacman -Syu
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain

g++ --version
gdb --version
Official MSYS2 installation
Fastest setup

Ubuntu / Debian

GCC + GDB

  1. 01Open Terminal and refresh the package index.
  2. 02Install build-essential for GCC, g++, make, and standard headers.
  3. 03Install GDB so VS Code can debug your program.
  4. 04Verify both tools before configuring the editor.
sudo apt update
sudo apt install build-essential gdb

g++ --version
gdb --version
Official VS Code Linux guide
No full Xcode required

macOS

Apple Clang + LLDB

  1. 01Open Terminal and request Apple Command Line Tools.
  2. 02Complete the system installation dialog and licence agreement.
  3. 03Use clang++ to compile C++; clang alone is the C compiler driver.
  4. 04Verify Clang and LLDB before opening VS Code.
xcode-select --install

clang++ --version
lldb --version
Official Apple installation guide

02 / Connect the editor

Make VS Code use your compiler.

Install the Microsoft C/C++ extension after the terminal checks work. If the terminal cannot find the compiler, VS Code cannot fix it.

Official VS Code C++ guide

01Install the extension

Open Extensions with Ctrl/Cmd + Shift + X, search “C/C++”, and install the extension published by Microsoft.

02Open a project folder

Create a folder for the program and open that folder—not only the .cpp file—using File → Open Folder or code .

03Select the compiler

Run “C/C++: Select IntelliSense Configuration” from the Command Palette and choose g++, clang++, or cl.exe.

04Build before debugging

Compile successfully in the integrated terminal first. Then use the play-button menu to create a matching build and debug task.

03 / Verify C++17

Compile something that needs C++17.

This sample uses structured bindings. If it builds with the standard flag and prints three lines, the compiler, standard library, terminal, and executable path are all working.

main.cpp

C++17 smoke test

A real language-feature check is more useful than only reading a version number.

#include <iostream>
#include <string>
#include <utility>
#include <vector>

int main() {
    std::vector<std::pair<std::string, int>> topics{
        {"arrays", 9}, {"trees", 8}, {"graphs", 10}
    };

    // Structured bindings are a C++17 feature.
    for (const auto& [name, lessons] : topics) {
        std::cout << name << " -> " << lessons << '
';
    }
}
16 linesUTF-8 · C++ study reference
terminal

Build and run

Use the command for your installed compiler. Keep warnings enabled from the beginning.

# GCC — Windows (MSYS2) or Linux
g++ -std=c++17 -Wall -Wextra -Wpedantic -g main.cpp -o main
./main

# Clang — macOS
clang++ -std=c++17 -Wall -Wextra -Wpedantic -g main.cpp -o main
./main

# MSVC — Developer Command Prompt on Windows
cl /std:c++17 /EHsc /W4 main.cpp
.\main.exe
11 linesUTF-8 · C++ study reference
-std=c++17

GCC and Clang language mode

/std:c++17

MSVC language mode

-Wall -Wextra

Useful compiler warnings

-g

Debug symbols for GDB or LLDB

04 / Troubleshoot

Fix the layer that failed.

Editor errors, compiler errors, linker errors, and runtime errors are different. Read the first useful error instead of reinstalling everything.

g++ is not recognized

The compiler is missing from PATH. On Windows, add C:\msys64\ucrt64\bin, then fully reopen VS Code and the terminal.

iostream: No such file

A complete C++ toolchain or its standard-library headers are missing. Reinstall the toolchain; an editor extension alone is not a compiler.

Undefined reference

Compile C++ with g++, not gcc, and include every required .cpp file in the build command.

The code builds but VS Code is red

Run “C/C++: Select IntelliSense Configuration” and choose the same compiler used in your terminal.

bits/stdc++.h is missing

That header is a non-standard GCC convenience. Prefer explicit headers such as <vector>, <queue>, <algorithm>, and <iostream>.

Program does not run on Windows

PowerShell uses .\main.exe. In the MSYS2 UCRT64 terminal, use ./main.exe or ./main.

Setup complete

Now learn the tools you will use in DSA.

Continue with containers, iterators, comparators, compiler warnings, sanitizers, and the C++ implementation patterns used throughout UCS301.

Open C++ toolkit
Use one compiler toolchain consistently for coursework and laboratory submissions.