liveBook · Manning

Dynamic linking

As explained in Systems Programming with Zig

Dynamic linking is a linking technique in which an executable records its dependency on a separately provided library that is loaded at runtime.

Dynamic linking records an executable’s reliance on a separately compiled library, which the operating system can load and run when needed. section 5.2.1

The practical trade-off is how library code reaches the executable:

  • Static linking copies library code into the executable; dynamic linking records a dependency on the library. section 5.2.1
  • Dynamic system-library dependencies can make a program behave differently or fail on systems with older library versions. Zig often favors static linking to avoid that deployment problem, while GLFW expects dynamic system libraries. section 7.2.1
Figure 5.2 What a simple executable actually contains
CH05 F02 hinsonhasty

Use the executable diagram to see where a library dependency fits. section 5.2.1

How Systems Programming with Zig covers it

How deep it goes
Defines dynamic linking and contrasts it with static linking, but does not detail the operating system’s loading mechanisms.
Examples
Uses Linux libc version mismatches and GLFW’s dynamically linked system libraries to illustrate compatibility risks.
What you can do after
Evaluate how system-library dependencies may affect program compatibility across systems, and contrast that risk with static linking.
How it connects
Connects dynamic linking to application binary interfaces, foreign-function interfaces, static linking, and system libraries.

Also explained in

Compare how 2 books explain dynamic linking →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Systems Programming with Zig. The section links point to the parts of the book it draws on.