Libraries in Linux are classified into two types:
1) Static Libraries:- The collection of object files kept together. When a program needs a function, that is stored in static library, it includes the header file that declares the function. The compiler combines the program code and linker links the library into an execuatble code.
Static Libraries are also called as archives that ends with .a extension.
e.g. /usr/lib/libc.a is a standard C library.
Disadvantage of Static Libraries:- In the static libraries the function code is included in the executable. So when we run many applications that use the same function code, we end up with many copies of same functions in memory.
2) Shared Libraries:- When a program uses a function in a shared library, then that code does not get included in the execuatable. Instead it references to shared code that will be made available at run time. So when that program is loaded in memory to execute, the functions references are resolved and calls are maded to shared libraries which will be loaded into memory.
So many applications uses a single copy of shared libraries. Also shared libraries can be updated independently of the applications that rely on it.
Shared libraries has the form libname.so.N
name - name of library so - extension N - major revision number
e.g. libc.so.5
Shared libraries(.so) are just like Dynamic Link Libraries(.dll) in Windows.
Comments