Software libraries consist of useful function utilities and classes that have been pre-written (and often pre-compiled) for broad general use. Applications often pass through multiple layers of libraries.

Compiled languages

In compiled languages, like C, static libraries are included at link time. At this point, it extracts the relevant object files from the library (archived in a .a file), and links together with the final .o file to produce an executable.

Dynamic libraries are also for reusable code (like the C standard library, saved in a .so file), but are included at runtime. Like static libraries, they collect several object files with function definitions. The operating system only has to load dynamic libraries in memory once, and share it with any applications that use it.

Static linking carries the drawback of preventing reuse of libraries. Any updates to static libraries also require the entire executable to be recompiled. One problem with dynamic linking is that if the ABI specification changes between versions, this may be unknown to the programmers.

In C/C++, all we need to include is the header files, which ensure type safety during compilation.

Sub-pages