C++: Running Code & Tools
Compiling C++
C++ is a compiled language. You need a compiler to translate source code into an executable.
g++ my_program.cpp -o my_program # compile with GCC (Linux, MinGW)
g++ -std=c++17 my_program.cpp -o my_program # specify C++ standard
clang++ my_program.cpp -o my_program # compile with Clang (macOS)
Running
./my_program # Linux / macOS
my_program.exe # Windows
Editors / IDEs
- VS Code — install the C/C++ extension pack by Microsoft (includes IntelliSense, debugging, code navigation)
- CLion — JetBrains IDE for C/C++ (paid, but full-featured)
- Visual Studio — Windows IDE with MSVC compiler, debugger, and profiler (free Community edition)
- Qt Creator — lightweight IDE for Qt-based projects
Build systems
For anything beyond one-file programs, use a build system:
cmake -B build && cmake --build build # CMake (cross-platform, most common)
make # Makefile (Unix)
CMake is the de-facto standard. It generates build files for your platform (Makefiles, Visual Studio solutions, etc.) from a CMakeLists.txt.
Package managers
- vcpkg — Microsoft's C++ package manager
- Conan — cross-platform C/C++ package manager
vcpkg install fmt # install the fmt library
conan install . --build=missing # Conan install
Debugging
- GDB (command line) — the GNU debugger
- LLDB (command line) — debugger for Clang
- VS Code or Visual Studio — GUI debugging with breakpoints, watches, and variable inspection
Quick check below!