Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How shared library locations are found at runtime

📅 2017-Nov-01 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

You have successfully compiled an executable that is linked with one or more external shared libraries. You can view the shared libraries that the executable is dependent on by using the ldd tool. When you actually run the executable, the dynamic linker-loader ld-linux looks for each dependent shared library in the following locations, in order:

See it in action

You can actually witness the loader searching directories to find the location of each shared library. To see this in action, try this command:

$ LD_DEBUG=libs ldd ./some_executable

In the output of this command, you will see that:

References: