There is an executable I want to install on a computer that I can't recompile that wasn't built as a package, and I want to download the libraries it requires to run them.

Below is part of the output from running ldd on it

libpango-1.0.so.0 => /usr/lib/i386-linux-gnu/libpango-1.0.so.0 (0xb702f000)
libcairo.so.2 => /usr/lib/i386-linux-gnu/libcairo.so.2 (0xb6f64000)
libatk-1.0.so.0 => /usr/lib/i386-linux-gnu/libatk-1.0.so.0 (0xb6f43000)
libsqlite3.so.0 => /usr/lib/i386-linux-gnu/libsqlite3.so.0 (0xb6e9e000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb6cf4000)
/lib/ld-linux.so.2 (0xb786e000)
libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xb6cd3000)
libgio-2.0.so.0 => /usr/lib/i386-linux-gnu/libgio-2.0.so.0 (0xb6b7c000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb6b4f000)

Is there a tool that can use this information to select which packages should be downloaded or better yet extract only the libraries listed and their dependencies, in order to minimize the disk usage? The system is running on a headless VM and the program will be displayed via VNC.

Although I suspect that a full blown graphics desktop will supply most of the libraries needed I want to download only the required libraries, their dependencies and just enough of the X Windows package to support it.

  • 1
    What OS? The packages and their names as well as the package manager change between distributions (and this is assuming you are running some kind of Linux).
    – terdon
    Nov 19, 2013 at 22:04
  • It is Debian and Ubuntu in this case
    – vfclists
    Jan 4, 2014 at 13:06
  • In that case, my answer should work for you.
    – terdon
    Jan 4, 2014 at 13:08
  • In fact I am just about to test it, belatedly. I plain forgot about it and just asked a similar question which caused this one to show as the top related question, LOL
    – vfclists
    Jan 4, 2014 at 13:11

3 Answers 3


You have not said which OS you are using so I am going to assume Linux and will use Debian as an example. The quick answer to your question is no as far as I know. This might be a useful workaround though:

ldd your_prog | awk '{print $1}' | sed 's/\..*//' | 
  while read n; do echo "----- $n ----"; apt-cache search ^$n; done

This will parse the ldd output and then run apt-cache (replace that with the equivalent for your OS) to search the repositories for packages whose name and description contains the first part of the library name returned by ldd.

This will not find all of them and will give too many results for some (like libc) but it could be helpful.

@FaheemMitha pointed out that apt-file might be a better way. For example:

ldd /bin/bash | awk '/=>/{print $(NF-1)}'  | 
 while read n; do apt-file search $n; done |
  awk '{print $1}' | sed 's/://' | sort | uniq

That will return a list of package names that provide the linked libraries.

  • 3
    apt-file search on the actual file on the right side of the arrow might be more effective. Nov 19, 2013 at 22:24
  • @FaheemMitha very good point, thanks. Answer edited.
    – terdon
    Nov 19, 2013 at 22:35
  • How can the command be adjusted to test for the existence of the library on the system in order to find those which need to be downloaded? I think the question I asked recently is more along that line. I am asking for it to be reopened.
    – vfclists
    Jan 4, 2014 at 14:14
  • @vfclists not worth it really, just apt-get install all of them and any that are already installed will be ignored.
    – terdon
    Jan 4, 2014 at 14:21
  • The reason is to create a VM with no superfluous libraries for quick downloads. Package installs contain a lot of unnecessary items and I only need the library files and their dependencies that are required by the executables.It also gives me a chance to hone my bash and Linux skills. No python.
    – vfclists
    Jan 4, 2014 at 15:06

@terdon's answer is great but it is even easier to do this using dpkg-query which unlike apt-file is installed by default on Debian systems.

ldd /bin/bash | awk '/=>/{print $(NF-1)}' | while read n; do dpkg-query -S $n; done | sed 's/^\([^:]\+\):.*$/\1/' | uniq

This produces a list of packages.

  • The problem with dpkg-query is that it only searches installed packages whereas apt-file will search all packages. Jun 16, 2021 at 22:42

Your best bet is to find a package that actually supports your distribution. But if that is not going to work for you then I know only one other way.

Run ldd as you have, then manually install those dependencies.

For example libpango-1.0.so.0 => /usr/lib/i386-linux-gnu/libpango-1.0.so.0 (0xb702f000)

For me would mean installing apt-get install libpango:i386 and praying that the version in Debian unstable was good enough.

You would need to go through each line of ldd, Google, look in your available repositories, and basically get lucky. Then install them one by one. Till the program actually runs. ldd will only work for "simple" programs though. Programs that call plugins or that run arbitrary code are a different matter all together. For those you will need to run from the console, and fix the crashes/errors as they happen.

That said, a binary only executable is horridly hard to maintain. You may want to consider using something else. If your distro is a little ahead, or a little behind the system that built that executable, you may never get it to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.