What Are Shared Libraries?
A shared library (also called a dynamic library or DSO — Dynamic Shared Object) is a compiled object file that is loaded into memory at run time and can be shared by multiple programs simultaneously. Unlike static libraries, shared library code lives in a single copy in memory, saving RAM and disk space.
This chapter covers the internals of how Linux creates, names, installs, versions, and upgrades shared libraries. Understanding this is essential for any Linux systems programmer, embedded developer, or BLE/driver developer who ships reusable code.
| Static Library (.a) | Shared Library (.so) |
|---|---|
| Code is copied into each executable at link time.
Every binary is self-contained. Changes require re-linking all programs. |
Code lives in one .so file on disk.
Multiple programs share one copy in RAM. Update the library → all programs benefit. |
| ⚠ Larger binaries, no live patching | ✔ Smaller binaries, easy updates |
Tutorial Files in This Series
Learn what ldconfig does, how /etc/ld.so.cache works, how soname symlinks are managed automatically, and how to use the -n option for private libraries.
Understand exactly when a library change is backward-compatible (minor version bump) versus when it breaks ABI and requires a new major version.
Step-by-step guide to installing minor and major version upgrades of a shared library while programs are already running — zero downtime upgrades.
What are .a and .so files, how are they built, what tools (ar, nm, readelf, objdump) are used, and when should you choose each type?
How ld-linux.so loads libraries at startup, lazy vs eager binding, LD_PRELOAD for function interposition, LD_DEBUG for diagnostics, and library constructors/destructors.
Load shared libraries explicitly at runtime using dlopen/dlsym/dlclose/dlerror — the foundation of plugin systems, codec loaders, and driver hot-loading.
Start Learning Now!
All tutorials are free. No login required.
