Search⌘ K
AI Features

Getting the Basics of Linking Right

Explore how linking works in C++ projects with CMake by understanding the structure of object files, the relocation process, and reference resolution. This lesson helps you grasp how compiled sources are combined into executable files and how CMake manages these linking steps for effective program building.

The life cycle of a C++ program consists of five main stages: writing, compiling, linking, loading, and execution. After correctly compiling all the sources, we need to put them together into an executable.

Structure of an object file

Object files produced in a compilation can't be executed by a processor directly. But why? To answer this, let's take a look at how a compiler structures an object file in the popular ELF format (used by ...

The structure of an object file
The structure of an object file

The compiler will prepare an object file for every translation unit ...