-
What is static vs dynamic linking?
-
Static
- Build a library whose code gets copied into the final executable when linking.
- File formats
- MacOS -
.a - Linux -
.a - Windows -
.lib
- MacOS -
-
Dynamic
- Build a library that stays as a separate file, and the executable loads it at runtime.
- File formats
- MacOS -
.dylib - Linux -
.so(shared object) - Windows -
.dll
- MacOS -
-
Static libMathLib.a | +----> App A (copy add()) +----> App B (copy add()) +----> App C (copy add())
-
Dynamic App A ----
App B -----+----> libMathLib.dylib App C ----/
cmake -S . -B build && cmake --build build# lldb commands
image list
image lookup --name add- What Does the C++ Linker Actually Do?
- What's the Difference Between Static and Dynamic Linking in C++?
- How Does C++ Link Static and Dynamic Libraries?
- What does the C++ compiler do when you link your code?
- cppreference.com
- learncpp.com
- ChatGPT and Gemini