Search courses, chapters, or pages...
Use a terminal prompt to move into a project folder, list files, and know which directory your commands affect. Connect simple commands like `pwd`, `cd`, and `ls` or `dir` to the files your compiler will see.
Use what you learned in the previous lesson to solve real-world problems.
Create a plain-text `.cpp` file and save it where your build command can find it. Tell source code apart from generated files such as object files and executables.
Check what you understood with a short quiz.
Read the smallest complete C++ program as the computer sees it: `main` is the starting point, braces hold its body, statements end with semicolons, and `return 0;` reports success.
Use `#include <iostream>` and `std::cout` to send a line of text to the terminal. Recognize why `<<` chains output pieces and why ` ` or `std::endl` moves to the next line.
Build one source file from the terminal with a compiler command such as `g++ hello.cpp -o hello`, `clang++ hello.cpp -o hello`, or MSVC’s `cl hello.cpp`. Identify the input file, compiler name, and output executable in the command.
Run the program you just built and notice the platform differences: `./hello` on macOS or Linux, and `hello.exe` or `.hello.exe` on Windows shells. Use the program’s printed output to confirm which executable actually ran.
Trace the path from `.cpp` source to a runnable program: preprocessing handles directives, compiling checks C++ and creates object code, and linking combines object code with libraries. Match common artifacts like `.o`, `.obj`, `.exe`, and extensionless Unix executables to those stages.
Use compiler messages to jump from an error to the file, line, and likely cause. Separate syntax errors, missing includes, and linker errors so you know whether to fix code text, a declaration, or the build command.
Add practical options such as `-std=c++20`, `-Wall`, and `-Wextra` to make the compiler use a known C++ version and report suspicious code early. Recognize the MSVC equivalents `/std:c++20` and `/W4` when working on Windows.
Practice the everyday loop: edit the `.cpp` file, build it again, run the new executable, and fix the next problem. Notice when you are accidentally running an old executable because the rebuild failed.
Recognize when a project uses a build tool instead of a single compiler command. Connect `CMakeLists.txt`, a separate `build` folder, and commands like `cmake --build` to the same compile-and-link work done by `g++`, `clang++`, or `cl`.
Review this chapter with practice based on your mistakes.