Skip to content

Instantly share code, notes, and snippets.

@dmigous
Last active October 13, 2015 15:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmigous/5ee8a6468098c9917eba to your computer and use it in GitHub Desktop.
Save dmigous/5ee8a6468098c9917eba to your computer and use it in GitHub Desktop.
How to find on what packages depends your library Debian / Ubuntu

How to find on what packages depends your library Debian / Ubuntu

When creating deb package for your project you need to specify at DEBIAN/control file at Depends: field to what packages your project depends. To do that you can invoke follwing command on all binaries and libraries that you want to put into your package. This will help you fill in Depends: field.

Before start you should install apt-file: # apt-get install apt-file

ldd $LIBRARY_PATH  | awk '/=>/{print $1}'  |   \
  while read n; do echo "=== $n maybe found at: ===" && apt-file search $n |   \
    awk '{print $1}' | sed 's/://' | sort; done | uniq

Example:

$ ldd /usr/lib/libmodplug.so.1  | awk '/=>/{print $1}'  | \
  while read n; do echo "=== $n ===" && apt-file search $n |  \
    awk '{print $1}' | sed 's/://' | sort; done | uniq
$ ldd /usr/lib/libmodplug.so.1  | awk '/=>/{print $1}'  |     while read n; do echo "=== $n ===" && apt-file search $n |       awk '{print $1}' | sed 's/://' | sort; done | uniq
=== libstdc++.so.6 ===
lib32stdc++6
lib32stdc++6-4.8-dbg
lib32stdc++6-4.9-dbg
libstdc++6
libstdc++6-4.8-dbg
libstdc++6-4.9-dbg
libx32stdc++6
libx32stdc++6-4.8-dbg
libx32stdc++6-4.9-dbg
=== libm.so.6 ===
libc6
libc6-i386
libc6-x32
=== libc.so.6 ===
libc6
libc6-i386
libc6-x32
=== libgcc_s.so.1 ===
lib32gcc1
lib32gcc1-dbg
libgcc1
libgcc1-dbg
libx32gcc1
libx32gcc1-dbg

So when you building deb package for your project, probably dependencies that you will put to your DEBIAN/control file are

Depends: libstdc++6, libc6, libgcc1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment