| Main index | Section 3 | 日本語 | Deutsch | Options |
The various libraries (followed by the loader flag):
| libbluetooth | |
|
( | |
| libc |
( |
| standard I/O routines | |
| see stdio(3) | |
| database routines | |
| see db(3) | |
| bit operators | |
| see bitstring(3) | |
| string operators | |
| see string(3) | |
| character tests and character operators
storage allocation | |
| see mpool(3) | |
| regular-expressions | |
| see regex(3) | |
| remote procedure calls (RPC) | |
| see rpc(3) | |
| time functions | |
| see time(3) | |
| signal handling | |
| see signal(3) | |
| libcalendar | |
|
( | |
| libcam | |
|
( | |
| libcrypt | |
|
( | |
| libcurses | |
|
( | |
| libcuse | |
|
( | |
| libcompat | |
|
( | |
| libdevinfo | |
|
( | |
| libdevstat | |
|
( | |
| libdwarf | |
|
( | |
| libelf | |
|
( | |
| libfetch | |
|
( | |
| libfigpar | |
|
( | |
| libgpio | |
|
( | |
| libgssapi | |
|
( | |
| libjail | |
|
( | |
| libkvm | |
|
( | |
| libl |
( |
| libm |
( |
| libmd |
( |
| libmp |
( |
| libpam | |
|
( | |
| libpcap | |
|
( | |
| libpmc | |
|
( | |
| libpthread | |
|
( | |
| libstdthreads | |
|
( | |
| libsysdecode | |
|
( | |
| libtermcap | |
|
( | |
| libusb | |
|
( | |
| libvgl | |
|
( | |
| liby |
( |
| libz |
( |
| /usr/lib/libc.a | the C library |
| /usr/lib/libc_p.a | |
| the C library compiled for profiling | |
| /usr/lib/libm.a | the math library |
| /usr/lib/libm_p.a | |
| the math library compiled for profiling | |
libc.so.7
Libraries with an
'.a'
suffix are static.
When a program is linked against a static library, all necessary library code
will be included in the binary.
This means the binary can be run even when the libraries are unavailable.
However, it can be inefficient with both disk space and memory usage
during execution.
The C compiler,
cc(1),
can be instructed to link statically by specifying the
Libraries with a '.so.X' suffix are dynamic libraries. When code is linked dynamically, the library code that the application needs is not included in the binary. Instead, data structures are added containing information about which dynamic libraries to link with. When the binary is executed, the run-time linker ld.so(1) reads these data structures and loads them into the process virtual address space. rtld(1) loads the shared libraries when the program is executed.
'X' represents the library version number of the library. In the example above, a binary linked with libc.so.8 would not be usable on a system where only libc.so.7 is available.
The advantages of dynamic libraries are that multiple instances of the same
library can share address space, and the physical size of the binary is
smaller.
A namespace per shared library is available via hidden visibility,
allowing multiple compilation units in a library to share things without
making them available to other libraries.
It is possible to load libraries dynamically via
dlopen(3).
The disadvantage is the added complexity that comes with loading the
libraries dynamically, and the extra time taken to load the libraries.
Of course, if the libraries are not available, the binary will be unable
to execute.
Calls across shared libraries are also slightly slower and cannot be
inlined, not even with link time optimization.
The C compiler,
cc(1),
can be instructed to link dynamically by specifying the
Shared libraries, as well as static libraries on architectures which produce
position-independent executables
(PIEs)
by default, contain position-independent code
(PIC).
Normally, compilers produce relocatable code.
Relocatable code needs to be modified at run-time, depending on where in
memory it is to be run.
The C compiler,
cc(1),
can be instructed to generate PIC code by specifying the
Static libraries are generated using the ar(1) utility. The libraries contain an index to the contents of the library, stored within the library itself. The index lists each symbol defined by a member of a library that is a relocatable object file. This speeds up linking to the library, and allows routines in the library to call each other regardless of their placement within the library.
| INTRO (3) | November 16, 2023 |
| Main index | Section 3 | 日本語 | Deutsch | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
