C++ needs a C++ compiler as well as an editor. Use g++ rather than gcc for the example so the C++ standard library is linked correctly.
What you need
- A C++ compiler such as g++
- A code editor; the VS Code C/C++ extension is optional
- A terminal
Set up your environment
- Install VS Code if desired, then install a compiler separately. The C/C++ editor extension does not supply a compiler.
- On Windows follow the official VS Code MinGW/MSYS2 guide. Install the UCRT64 toolchain and add its bin folder to PATH as documented. On Linux use your distribution compiler packages; on macOS install the command-line developer tools.
- Reopen the terminal and verify
g++ --version. Create a project folder and save the source file with the .cpp extension. - Compile from the folder containing the source file, then run the executable. The commands below show a Windows terminal. On Linux/macOS choose an output name without .exe and run it with ./hello.
Your first check
Save as hello.cpp
#include <iostream>
int main() {
std::cout << "Hello from w1coding.com\n";
return 0;
}Run or verify
g++ -std=c++17 hello.cpp -o hello.exe
.\hello.exeExpected result: The terminal prints Hello from w1coding.com.
Common setup problems
- An editor extension provides editing support; install the compiler toolchain separately.
- On Linux/macOS compile to hello and run
./hello. Windows examples use.\hello.exe.
Official documentation
Guide reviewed 17 November 2026. Check the linked vendor documentation for current supported versions and operating systems.