8. Shared libraries
Packages containing shared libraries must be constructed with a little care to make sure that the shared library is always available. This is especially important for packages whose shared libraries are vitally important, such as the C library (currently libc6
).
This section deals only with public shared libraries: shared libraries that are placed in directories searched by the dynamic linker by default or which are intended to be linked against normally and possibly used by other, independent packages. Shared libraries that are internal to a particular package or that are only loaded as dynamic modules are not covered by this section and are not subject to its requirements.
A shared library is identified by the SONAME
attribute stored in its dynamic section. When a binary is linked against a shared library, the SONAME
of the shared library is recorded in the binary’s NEEDED
section so that the dynamic linker knows that library must be loaded at runtime. The shared library file’s full name (which usually contains additional version information not needed in the SONAME
) is therefore normally not referenced directly. Instead, the shared library is loaded by its SONAME
, which exists on the file system as a symlink pointing to the full name of the shared library. This symlink must be provided by the package. Run-time shared libraries describes how to do this. 1
When linking a binary or another shared library against a shared library, the SONAME
for that shared library is not yet known. Instead, the shared library is found by looking for a file matching the library name with .so
appended. This file exists on the file system as a symlink pointing to the shared library.
Shared libraries are normally split into several binary packages. The SONAME
symlink is installed by the runtime shared library package, and the bare .so
symlink is installed in the development package since it’s only used when linking binaries or shared libraries. However, there are some exceptions for unusual shared libraries or for shared libraries that are also loaded as dynamic modules by other programs.
This section is primarily concerned with how the separation of shared libraries into multiple packages should be done and how dependencies on and between shared library binary packages are managed in Debian. Libraries should be read in conjunction with this section and contains additional rules for the files contained in the shared library packages.
This is a convention of shared library versioning, but not a requirement. Some libraries use the SONAME
as the full library file name instead and therefore do not need a symlink. Most, however, encode additional information about backwards-compatible revisions as a minor version number in the file name. The SONAME
itself only changes when binaries linked with the earlier version of the shared library may no longer work, but the filename may change with each release of the library. See Run-time shared libraries for more information.