8
Linking Executables and Libraries
You might assume that once we’ve successfully compiled the source code into a binary file, our role as build engineers is complete. However, that’s not entirely true. While binary files do contain all the necessary code for a CPU to execute, this code can be distributed across multiple files in a complex manner. We wouldn’t want the CPU to scour different files searching for individual code snippets. Instead, our goal is to consolidate these separate units into a single file. To achieve this, we use a process known as linking.
A quick look shows that CMake has few linking commands, with target_link_libraries()
being the main one. Why dedicate a whole chapter to a single command then? Unfortunately, almost ...
Get Modern CMake for C++ - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.