Build Systems¶
C++ code needs to be compiled and linked. While you can use the compiler directly, build systems automate this process.
The Compilation Process¶
- Preprocessing: Handles
#include,#define, etc. - Compilation: Translates C++ to Assembly/Machine Code (Object files
.o). - Linking: Combines object files and libraries into an executable.
Make¶
The classic build tool. Uses a Makefile.
CMake¶
The modern standard. It generates build files (like Makefiles) for you. It is cross-platform.
CMakeLists.txt¶
Building with CMake¶
Libraries¶
- Static Library (
.a/.lib): Code is copied into your executable. Larger size, no runtime dependency. - Dynamic/Shared Library (
.so/.dll): Code is loaded at runtime. Smaller executable, requires library to be present.