Compile & Run in C++
From the C++ cheat sheet · Getting Started · verified Jul 2026
Compile & Run
Build with a modern standard and useful warnings.
cpp
// Quick Reference
g++ -std=c++23 -Wall main.cpp -o main
./main💡 Always pass -std=c++23 (or your target) - the default standard is often older.
⚡ -Wall -Wextra surface real bugs early; treat warnings as errors with -Werror.
📌 Angle-bracket includes <...> search system paths; quotes "..." search locally first.
🟢 C++ is compiled ahead of time - fix all compile errors before you get a binary.
compilecli