Amethyst Linux

Static and dynamic linking

To understand linking, one must first understand how executables and libraries work. On most modern operating systems, you will find both executable binaries and libraries, both of which contain code that are used to run programs. Libraries contain code which is meant to be included by executables and other libraries. Executables are the actual programs that the user of an operating system actually run, which (almost) always depend on libraries in order to run. There are two options for connecting the executables to the libraries they depend on: Static linking, and dynamic linking.

Static linking means that the necessary parts of the library are copied into the final executable file, just as if you included the original code itself into the program. This means that the resulting executable file is completely self-contained, and will run exactly the same way on every system, no matter what libraries are installed. (That is, as long as the kernel & programs it interacts with behave as expected...) This is the way code used to be compiled for a long time, and some operating systems still use this when dynamic linking would be impossible or less convenient.

Dynamic linking means that the symbols are copied from the library instead of the code. When the executable is run, the symbols are used to find the proper code to run in the library. This may have pros and cons depending on the context the library is used in.

Mainstream linux distributions generally only provide dynamically linked executables and libraries, with the rare exception of offering statically linked executables for the sake of recovering the operating system in the event that dynamically linked executables aren't working properly. There are a few niche distros that offer statically linked packages as the default, but they usually forego dynamic linking entirely. My personal opinion is that both can be useful depending on the circumstances, so I think it makes sense to offer both as an option.