Skip to main content

ldd utility

While playing with a binary, which happened to be openvpn, I discovered that I can't run it, for a very misterious reason: cannot open shared object file: No such file or directory

Obviously that means that a dynamic library the binary was linked went missing, but I needed more info about the matter.

Turns out there's a tool that is able to tell you everything there is to know about a binary and the libraries it's using. It's called ldd and it's great. With a simple ldd ./openvpn I was able to infer that much of useful insights about the issue that forced me to dig deeply:

$> ldd ./openvpn =>  (0x00007ffd291c7000) => /lib/x86_64-linux-gnu/ (0x00007f0932f11000) => /usr/lib/x86_64-linux-gnu/ (0x00007f0932cf9000) => not found => not found => /lib/x86_64-linux-gnu/ (0x00007f0933571000) => /lib/x86_64-linux-gnu/ (0x00007f0932af5000) => /lib/x86_64-linux-gnu/ (0x00007f093272b000) => /lib/x86_64-linux-gnu/ (0x00007f0932509000) => /lib/x86_64-linux-gnu/ (0x00007f0932301000) => /lib/x86_64-linux-gnu/ (0x00007f09320df000) => /lib/x86_64-linux-gnu/ (0x00007f0931dfe000) => /lib/x86_64-linux-gnu/ (0x00007f0931be1000)
  /lib64/ (0x00007f09333eb000) => /lib/x86_64-linux-gnu/ (0x00007f0931971000) => /lib/x86_64-linux-gnu/ (0x00007f093175d000)

With its help I discovered that I have to missing libraries and Turns out they're both provided by OpenSSL 1.1. Because I was not able to rely on openssl=1.1 being available on a lot of systems -- I had to re-compile openvpn against OpenSSL 1.0.0 (also that was because statically linking openssl and openvpn is damn hard. Anyways, ldd was able to infer that the new binary uses openssl 1.0!

$> ldd ./openvpn =>  (0x00007ffebbd73000) => /lib/x86_64-linux-gnu/ (0x00007f7933703000) => /usr/lib/x86_64-linux-gnu/ (0x00007f79334eb000) => /lib/x86_64-linux-gnu/ (0x00007f79330a6000) => /lib/x86_64-linux-gnu/ (0x00007f7932e3d000)
------------^ => /lib/x86_64-linux-gnu/ (0x00007f7932a73000) => /lib/x86_64-linux-gnu/ (0x00007f793286f000)
  /lib64/ (0x00007f7933925000)

What a small and great utility, do use it, it won't ever lie to you.

Also, note that ldd is Linux only, but there's a similar utility available on MacOS -- it's called otool.

Profile picture

Andrei Glingeanu's notes and thoughts. You should follow him on Twitter, Instagram or contact via email. The stuff he loves to read can be found here on this site or on goodreads. Wanna vent or buy me a coffee?