Technology and General Blog

In Linux methods, we constantly function with executable files possibly in the terminal or graphical applications. Executables have shared libraries, which are files that are shared and reused across plans. In windows, these are ordinarily in the sort of DDL information. In Linux, having said that, they are in the variety of .o or .so documents.

This guide will show you how to use the ldd command-line utility to present shared objects and the dependencies in an executable.

What is Ldd

Ldd is a highly effective command-line tool that permits buyers to watch an executable file’s shared object dependencies. A library refers to 1 or additional pre-compiled sources such as functions, subroutines, classes, or values. Every single of these means is combined to make libraries.

In Linux, library documents are generally found in /lib or /usr/lib directories. Libraries support help you save time for the reason that courses can repurpose and use them as they see in good shape.

There are two forms of libraries:

  • Static libraries
  • Dynamic or Shared Libraries

How to Set up The Ldd command

Generally, you will locate the ldd command available in virtually any Linux distribution. Even so, in case it is unavailable, you can put in it by making use of the command:

sudo apt-get put in libc-bin

With the command put in, we can get started employing it.

Basic Ldd Command Usage

The standard syntax for the ldd command is fairly simple. By default, executing the ldd command exhibits the shared item dependencies.

The syntax is as:

For instance, to show the shared library dependencies of the bash binary, we use the command:

The previously mentioned command shows the dependencies as:

The to start with segment exhibits a virtual dynamic shared object (VDSO). The 2nd line exhibits the path of the ELF interpreter that is hardcoded into the executable, and the remaining section exhibits the memory at which the library is loaded.

Ldd Options

We use ldd options to modify the actions of the command. Supported options contain:

  • -v – Verbose manner, which prints all data.
  • -u – Demonstrates unused immediate dependencies
  • -d – Executes details relocation and shows lacking ELF objects.
  • -r – executes knowledge and perform relocation and exhibits missing ELF objects and functions.

Display in depth output

To clearly show the dependencies of a binary with specific facts, we can move the -v flag to the ldd command as:

Ldd Present Unused Immediate Dependencies

Present unused immediate dependencies with the -u flag as:

Note: Ldd only performs with dynamic executables. If applied on a non-dynamic executable, it will screen an error as:

In Conclusion

This tutorial included how to use the ldd command in Linux and get shared library dependency data for dynamic executables. If you learned one thing from this tutorial, share it with other people.

If you are on the lookout for specific facts, think about the next gentleman internet pages:

Leave a Reply

Your email address will not be published. Required fields are marked *