dynamic-linking

Explain Linux dynamic linking, RPATH, soname, dlopen, and LD_PRELOAD.

159|20|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill dynamic-linking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dynamic-linking
Source: https://github.com/mohitmishra786/low-level-dev-skills/tree/main/skills/binaries/dynamic-linking
Command: npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill dynamic-linking

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill demystifies the complexities of dynamic linking on Linux, helping you resolve library loading errors, optimize search paths, and manage symbol visibility effectively.

Core Features & Use Cases

  • Troubleshoot Library Loading: Diagnose and fix "cannot open shared object file" errors.
  • Configure Search Paths: Understand and set RPATH, RUNPATH, and LD_LIBRARY_PATH.
  • Manage Versioning: Implement soname versioning for shared libraries.
  • Plugin Systems: Utilize dlopen and dlsym for dynamic plugin architectures.
  • Interposition: Use LD_PRELOAD for debugging and overriding symbols.
  • Symbol Visibility: Control which symbols are exported from shared libraries.
  • Use Case: You've built a shared library but your application can't find it at runtime. This Skill guides you through setting the correct RPATH or ensuring the library is in the system's search path.

Quick Start

Use the dynamic-linking skill to debug why your application cannot find the shared library 'libexample.so'.

Frequently Asked Questions about dynamic-linking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix the "cannot open shared object file" error for a Linux shared library?

To fix the "cannot open shared object file" error, you must configure dynamic linking search paths by setting RPATH or RUNPATH during compilation, or by using the LD_LIBRARY_PATH environment variable to locate the shared library.

What is the difference between RPATH and RUNPATH for shared library loading?

RPATH and RUNPATH are dynamic linker search path configurations that differ in precedence; RPATH is checked before LD_LIBRARY_PATH while RUNPATH is checked after, affecting how shared library dependencies are resolved at runtime.

How do I use LD_PRELOAD to override functions in a shared library?

LD_PRELOAD is an environment variable used for symbol interposition, allowing you to override specific functions in shared libraries by loading your custom library first, which is highly effective for debugging ELF binaries.

How do I resolve an "undefined symbol" error when loading an ELF shared library?

Resolving an "undefined symbol" error requires checking symbol visibility controls and ensuring the dynamic linker can locate all dependencies, verifying that exported symbols in the shared library match application expectations.

Can I use dlopen and dlsym to build a dynamic plugin system on Linux?

Yes, you can use dlopen and dlsym to load shared libraries dynamically at runtime, enabling flexible plugin architectures without recompiling your application or linking the libraries at build time.

When do I need to configure soname versioning for shared libraries?

You need soname versioning when managing shared library updates to ensure ABI compatibility, allowing the dynamic linker to load correct library versions and prevent application crashes from incompatible symbol changes.