Tech News
← Back to articles

The .a File Is a Relic: Why Static Archives Were a Bad Idea All Along

read original related products more articles

From the perspective of an SDK provider, we must not limit our customers. As such, we are expected to provide both the dynamic linking option, as well as the static linking one. And what will this mean?

Dynamic linking — Provide Shared Object ( .so ) libraries, as well as matching compilation ( .pc ) definitions.

) libraries, as well as matching compilation ( ) definitions. Static linking — Provide Static Archive ( .a ) files, as well as matching compilation ( .pc ) definitions.

When we bundle the installation of our SDK for some Linux distros, we might decide to adapt it to the expected delivery per distro. For instance, when one installs libpng on Red Hat Linux, the installation will not include a static archive ( .a ) file, although it will include it on an Ubuntu installation.

Here’s a reminder of the gist of each of the loading methods.

Dynamic Linking 101

The library is taken pretty much “as-is”, and mapped to the virtual address space of the program at load time.

One notable advantage is that security fixes can be provided through updated library versions, as long as the ABI was kept intact (no breaking changes). Applying this update will simply require to reboot the program that uses the library, but will not require a full-blown recompilation.

The file format used for Shared Objects ( .so ) is the same ELF file format as used for “regular” executables, with some slight differences at the file’s header.

Static Linking 101

... continue reading