Lesson 2 of 45
C++Lesson 2: Setting Up Development Environment
10 min
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 2 of 45
C++10 min
Keep these ideas in mind as you work through the lesson.
Before you can write C++ code you need a compiler, a linker, and an editor or IDE. The most common toolchains are:
sudo apt-get install build-essential or brew install gcc.brew install llvm.Once a compiler is installed, you need an editor. VS Code is lightweight and works cross‑platform. Below is a minimal tasks.json that lets you build and run a single‑file program with g++:
{
\"version\": \"2.0.0\",
\"tasks\": [
{
\"label\": \"build and run\",
\"type\": \"shell\",
\"command\": \"g++\",
\"args\": [
\"-std=c++20\",
\"${file}\",
\"-o\",
\"${fileDirname}/${fileBasenameNoExtension}\"
],
\"group\": {
\"kind\": \"build\",
\"isDefault\": true
},
\"problemMatcher\": \"$gcc\",
\"detail\": \"Compiled with g++\"
}
]
}
If you prefer a build system, CMake is the de‑facto standard. A tiny CMakeLists.txt looks like:
cmake_minimum_required(VERSION 3.15)
project(HelloCxx LANGUAGES CXX)
add_executable(hello main.cpp)
set_target_properties(hello PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES)
Tip: Install the C/C++ extension from Microsoft in VS Code. It provides IntelliSense, debugging, and linting out of the box.
<Alert type="info">If you are on Windows and prefer a full‑featured IDE, Visual Studio Community offers a one‑click install for the MSVC toolchain and a powerful debugger.