Starting with version 0.22, KLayout offers a library concept. Libraries are a way to import cell layout into a layout from the outside and thus a convenient way to provide standard building blocks for the layout. Using a cell from a library is easy: when asked for a cell, select the library where to take the cell from and choose a cell from that library.
Libraries are basically just foreign layouts that are virtually linked to the current layout. When a cell is imported from a library, it is copied into the current layout, so that the current layout by itself is a valid entity.
When a layout containing library references is saved, KLayout stores some meta information in that file which allows it to restore the library links and related information. For GDS, that meta information is stored in a separate top cell. For OASIS, the meta information is stored in special per-cell properties. For other formats, the meta information is not stored currently.
Libraries can be provided in several ways:
As ordinary layout files: Such libraries are simple layout files (GDS, OASIS or other support format). KLayout looks up those libraries in the "libraries" subfolders of the search path and gathers all layout files it finds there into the library repository.
The search path usually includes the installation site (where the KLayout executable resides) and the application folder (i.e. "~/.klayout" on Linux). Hence libraries can be installed locally (i.e. in "~/.klayout/libraries") or globally (at the installation site).
For GDS files, the library name will be the LIBNAME of the GDS file. Otherwise it will be the name of the library file minus the extension.
Starting with version 0.25, libraries can be provides through packages. This means, they can be downloaded from some repository and can be managed within the package manager. Library installation is very simple this way. Library deinstallation too. See About Packages for details about packages.