Pcornel
Linux · Software & Source

Shared Libraries

Cheat sheet · https://pcornel.dk/topic.php?topic=2909

Back to the Topic

Answer

Shared libraries (.so) are loaded at runtime by the dynamic linker (ld.so), which searches RPATH, LD_LIBRARY_PATH, the ldconfig cache (/etc/ld.so.conf.d) and default paths.

Remember

For libraries in /usr/local/lib or /opt, add the path to /etc/ld.so.conf.d/<name>.conf and run ldconfig. Avoid global LD_LIBRARY_PATH. Check which library is actually loaded with ldd.

First checks

  • git status / git log --oneline -5 — repository state
  • ldd <binary> — shared libraries
  • ldconfig -p | grep <lib> — libraries in the linker cache
  • make --version; gcc --version — build tools

Verify in this order

program starts → ld.so reads needed sonames → searches RPATH/env/cache/defaults → loads libraries

Where it usually breaks

First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2909

Confirmation

Confirm action

Continue?