Linux
    Overview
    Process
    Sockets
    File
    File System Hierarchy
    System Calls
    Libraries
    Device
    systemd
    Service
    namespaces
    Memory
    Modules
    Signals
    System Monitoring
    Desktop Environment
    Users and Groups
    Logs
    Network
    Terminal
    GNU

libs

Updated: 2022-10-13
  • .so: "shared-object", shared library, "dynamically linked" to programs at runtime, loaded only when needed. Like .dll in windows, .dylib in macOS (dynamic library extension).
  • .a: "Archive libraries", statically linked: when you compile your program with -c option in gcc. If there's any change in library, you need to compile and build your code again.
  • .ko: Loadable kernel modules: are object files that are used to extend the kernel of the Linux Distribution. Live in /lib/modules/ folder.

.so

  • a symlink which does not have a number associated
  • Each file has a different number at the end of it. These numbers represent versions of the library.
$ ls -lah /lib/x86_64-linux-gnu/libLLVM-11.so*

/lib/x86_64-linux-gnu/libLLVM-11.so -> libLLVM-11.so.1
/lib/x86_64-linux-gnu/libLLVM-11.so.1

Often found in the following Linux directories:

/​lib
/​usr/​lib
/​usr/​local/​lib

lists the runtimes dependencies of ls.

$ ldd `which ls`

To find some so files in cache: (-p = --print-cache)

$ ldconfig -p

View a list of the functions an SO file contains.

$ nm -D /lib/x86_64-linux-gnu/libc.so.6

Get metadata (elf=Executable and Linkable Format, ELF is the standard binary format on operating systems such as Linux.)

$ readelf -d /lib/x86_64-linux-gnu/libLLVM-11.so.1

The advantage of .so (shared object) over .a library is that they are linked during the runtime i.e. after creation of your .o file -o option in gcc. So, if there's any change in .so file, you don't need to recompile your main program.