Introduction

Let’s learn about compiling C++ sources into executables and libraries.

Complexities of the compilation process

Simple compilation scenarios are usually handled by a default configuration of a toolchain or just provided out of the box by an IDE. However, in a professional setting, business needs often call for something more advanced. It could be a requirement for higher performance, smaller binaries, more portability, testing support, or extensive debugging capabilities—you name it. Managing all of these in a coherent, future-proof way quickly becomes a complex, tangled mess (especially when there are multiple platforms to support).

The process of compilation is often not explained well enough in books on C++ (in-depth subjects such as virtual base classes seem to be more interesting). We'll go through the basics to ensure success when things don't go as planned. We'll discover how compilation works, what its internal stages are, and how they affect the binary output.

After that, we will focus on the prerequisites—we'll discuss what commands we can employ to tweak a compilation, how to require specific features from a compiler, and how to provide the compiler with the input files that it has to process.

Get hands-on with 1200+ tech skills courses.