Lesson 12 of 45 · C++
Lesson 2: Setting Up Development Environment
Duration: 10 min
Lesson 12 of 45 · C++
Duration: 10 min
sudo apt-get install build-essential or brew install gcc.\n- Clang – bundled with Xcode on macOS and also available via brew install llvm.\n- MSVC – comes with Visual Studio 2022 (Community edition works fine).\n- MinGW‑w64 – provides GCC for Windows.\n\nOnce 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++:\njson\n{\n \"version\": \"2.0.0\",\n \"tasks\": [\n {\n \"label\": \"build and run\",\n \"type\": \"shell\",\n \"command\": \"g++\",\n \"args\": [\n \"-std=c++20\",\n \"${file}\",\n \"-o\",\n \"${fileDirname}/${fileBasenameNoExtension}\"\n ],\n \"group\": {\n \"kind\": \"build\",\n \"isDefault\": true\n },\n \"problemMatcher\": \"$gcc\",\n \"detail\": \"Compiled with g++\"\n }\n ]\n}\n\n\nIf you prefer a build system, CMake is the de‑facto standard. A tiny CMakeLists.txt looks like:\ncmake\ncmake_minimum_required(VERSION 3.15)\nproject(HelloCxx LANGUAGES CXX)\nadd_executable(hello main.cpp)\nset_target_properties(hello PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES)\n\n\n> Tip: Install the C/C++ extension from Microsoft in VS Code. It provides IntelliSense, debugging, and linting out of the box.\n\n---\n\n<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.