Ch1: Compile

The Compile chapter begins with the most minimal C++ program:

int main() {}

There is no printing, no input, just the bare minimum entry point. From here, we explore how to turn this source code into a binary executable.

Tools We Will Use

To keep things modern and lightweight, we will use:

We will not use Microsoft Visual C++ in this tutorial.

Compiling Across Platforms

Using pure terminal commands, we will learn how to produce different kinds of binaries:

This chapter emphasizes understanding compilation without relying on IDEs or build systems. Just the command line, the compiler, and the simplest C++ program.

Workflow

The workflow is straightforward:

  1. Install the PWA Store and PWA version of VS Code.
  2. Install a compiler (Clang or GCC). If you are compiling Windows programs with Clang, also install the Windows MSVC Sysroot.
  3. Write int main() {} in a new file main.cpp.
  4. Open a terminal and run gcc main.cpp -o main or clang main.cpp -o main.
  5. Observe the generated binary (main.exe, a.out, or main depending on platform).

This exercise shows how C++ source code becomes a runnable program, even with no output.