dpkg-shlibdeps(1)

🌸 NAME 🌸

okay so this is dpkg-shlibdeps(1) from the dpkg suite, and she is literally the manual page for generating shared library substvar dependencies πŸ’–. dpkg-shlibdeps is the main character who calculates shared library dependencies for executables named in its arguments. No cap.

✨ SYNOPSIS ✨

dpkg-shlibdeps [option...] [-e] executable [option...]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay bestie, here's the vibe: dpkg-shlibdeps calculates shared library dependencies for executables named in its arguments. The dependencies are added to the substitution variables file debian/substvars as variable names shlibs:dependency-field, where dependency-field is a dependency field name. Any other variables starting with shlibs: are removed from the file. periodt πŸ’….

dpkg-shlibdeps has two possible sources of information to generate dependency information. Either symbols files or shlibs files. For each binary that dpkg-shlibdeps analyzes, it finds out the list of libraries that it's linked with. Then, for each library, it looks up either the symbols file, or the shlibs file (if the former doesn't exist or if debian/shlibs.local contains the relevant dependency). Both files are supposed to be provided by the library package and should thus be available as /var/lib/dpkg/info/package.symbols or /var/lib/dpkg/info/package.shlibs. The package name is identified in two steps: find the library file on the system (looking in the same directories that ld.so would use), then use dpkg -S library-file to lookup the package providing the library. iykyk 🫢.

πŸ’– Symbols files πŸ’–

Symbols files contain finer-grained dependency information by providing the minimum dependency for each symbol that the library exports. The script tries to find a symbols file associated to a library package in the following places (first match is used):

  • debian/*/DEBIAN/symbols β€” Shared library information generated by the current build process that also invoked dpkg-shlibdeps. They are generated by dpkg-gensymbols(1). They are only used if the library is found in a package's build tree. The symbols file in that build tree takes precedence over symbols files from other binary packages. iconic behavior ✨.
  • /etc/dpkg/symbols/package.symbols.arch, /etc/dpkg/symbols/package.symbols β€” Per-system overriding shared library dependency information. arch is the architecture of the current system (obtained by dpkg-architecture -qDEB_HOST_ARCH).
  • Output from dpkg-query --control-path package symbols β€” Package-provided shared library dependency information. Unless overridden by --admindir, those files are located in /var/lib/dpkg.

While scanning the symbols used by all binaries, dpkg-shlibdeps remembers the (biggest) minimal version needed for each library. At the end of the process, it is able to write out the minimal dependency for every library used (provided that the information of the symbols files are accurate). lowkey obsessed with that πŸŽ€.

As a safe-guard measure, a symbols file can provide a Build-Depends-Package or Build-Depends-Packages meta-information field and dpkg-shlibdeps will extract the minimal version required by the corresponding package in the Build-Depends field and use this version if it's higher than the minimal version computed by scanning symbols. fr fr, that's the safety net πŸ¦‹.

πŸŽ€ Shlibs files πŸŽ€

Shlibs files associate directly a library to a dependency (without looking at the symbols). It's thus often stronger than really needed but very safe and easy to handle. very "simple and effective, we love her" energy πŸ’….

The dependencies for a library are looked up in several places. The first file providing information for the library of interest is used:

  • debian/shlibs.local β€” Package-local overriding shared library dependency information.
  • /etc/dpkg/shlibs.override β€” Per-system overriding shared library dependency information.
  • debian/*/DEBIAN/shlibs β€” Shared library information generated by the current build process that also invoked dpkg-shlibdeps. They are only used if the library is found in a package's build tree. The shlibs file in that build tree takes precedence over shlibs files from other binary packages.
  • Output from dpkg-query --control-path package shlibs β€” Package-provided shared library dependency information. Unless overridden by --admindir, those files are located in /var/lib/dpkg.
  • /etc/dpkg/shlibs.default β€” Per-system default shared library dependency information.

The extracted dependencies are then directly used (except if they are filtered out because they have been identified as duplicate, or as weaker than another dependency). periodt πŸ’–.

πŸ’… OPTIONS πŸ’…

dpkg-shlibdeps interprets non-option arguments as executable names, just as if they'd been supplied as -eexecutable. Okay bestie, let's go through the whole menu πŸ“.

  • -eexecutable β€” Include dependencies appropriate for the shared libraries required by executable. This option can be used multiple times.
  • -ldirectory β€” Prepend directory to the list of directories to search for private shared libraries. This option can be used multiple times.
Note, bestie: Use this option instead of setting LD_LIBRARY_PATH, as that environment variable is used to control the run-time linker and abusing it to set the shared library paths at build-time can be problematic when cross-compiling for example. Supported since dpkg 1.17.0. 🫢
  • -ddependency-field β€” Add dependencies to be added to the control file dependency field dependency-field. (The dependencies for this field are placed in the variable shlibs:dependency-field.)

The -ddependency-field option takes effect for all executables after the option, until the next -ddependency-field. The default dependency-field is Depends.

If the same dependency entry (or set of alternatives) appears in more than one of the recognized dependency field names Pre-Depends, Depends, Recommends, Enhances or Suggests then dpkg-shlibdeps will automatically remove the dependency from all fields except the one representing the most important dependencies.

  • --package=package β€” Define the package name.

When specified, the package name will be used to change defaults based on the binary package metadata in debian/control.

If the package is Essential: yes, then the default dependency field is Pre-Depends, otherwise Depends. The default package type is set from the Package-Type field. The package is added to the set of packages excluded by -x.

Supported since dpkg 1.22.7. ✨

  • -pvarname-prefix β€” Start substitution variables with varname-prefix: instead of shlibs:. Likewise, any existing substitution variables starting with varname-prefix: (rather than shlibs:) are removed from the substitution variables file.
  • -O[filename] β€” Print substitution variable settings to standard output (or filename if specified), rather than being added to the substitution variables file (debian/substvars by default).

Support for optional argument since dpkg 1.17.2.

  • -ttype β€” Prefer shared library dependency information tagged for the given package type. If no tagged information is available, falls back to untagged information. The default package type is deb. Shared library dependency information is tagged for a given type by prefixing it with the name of the type, a colon, and whitespace.
  • -Llocal-shlibs-file β€” Read overriding shared library dependency information from local-shlibs-file instead of debian/shlibs.local.
  • -Tsubstvars-file β€” Write substitution variables in substvars-file; the default is debian/substvars.
  • -v β€” Enable verbose mode. Numerous messages are displayed to explain what dpkg-shlibdeps does.

Supported since dpkg 1.14.8.

  • -xpackage β€” Exclude the package from the generated dependencies. This is useful to avoid self-dependencies for packages which provide ELF binaries (executables or library plugins) using a library contained in the same package. This option can be used multiple times to exclude several packages.

Supported since dpkg 1.14.8. πŸ’€ no self-dependency drama, please.

  • -Spackage-build-dir β€” Look into package-build-dir first when trying to find a library. This is useful when the source package builds multiple flavors of the same library and you want to ensure that you get the dependency from a given binary package. You can use this option multiple times: directories will be tried in the same order before directories of other binary packages.

Supported since dpkg 1.14.15.

  • -Ipackage-build-dir β€” Ignore package-build-dir when looking for shlibs, symbols, and shared library files. You can use this option multiple times.

Supported since dpkg 1.18.5.

  • --ignore-missing-info β€” Do not fail if dependency information can't be found for a shared library.
Careful, bestie: Usage of this option is discouraged, all libraries should provide dependency information (either with shlibs files, or with symbols files) even if they are not yet used by other packages. Supported since dpkg 1.14.8. πŸ™ˆ
  • --warnings=[value|string[,...]] β€” Select the set of warnings that can be emitted by dpkg-shlibdeps.

The warnings can be selected from a comma-separated list of symbolic names (since dpkg 1.22.12), or from a value denoting a bit field for these warnings.

  • symbol-not-found (bit 0, value 1) β€” Selects the warning β€œsymbol sym used by binary found in none of the libraries”.

Enabled by default.

  • avoidable-dependency (bit 1, value 2) β€” Selects the warning β€œpackage could avoid a useless dependency”.

Enabled by default.

  • useless-linkage (bit 2, value 4) β€” Select the warning β€œbinary should not be linked against library”.

Supported since dpkg 1.14.17.

  • --admindir=dir β€” Change the location of the dpkg database. The default location is /var/lib/dpkg.

Supported since dpkg 1.14.0.

  • -?, --help β€” Show the usage message and exit.
  • --version β€” Show the version and exit.

🌈 ENVIRONMENT 🌈

  • DEB_HOST_ARCH β€” Sets the host architecture. This affects the objects and symbols files searched for and their default search pathnames.
  • DPKG_COLORS β€” Sets the color mode. The currently accepted values are: auto (default), always and never.

Supported since dpkg 1.18.5.

  • DPKG_NLS β€” If set, it will be used to decide whether to activate Native Language Support, also known as internationalization (or i18n) support. The accepted values are: 0 and 1 (default).

Supported since dpkg 1.19.0. 🌸

πŸ’– DIAGNOSTICS πŸ’–

ok so real talk: dpkg-shlibdeps literally analyzes the whole set of symbols used by every single binary in the package it's generating πŸ‘€ which means it can absolutely clock things and emit warnings in several cases. and these warnings? they're not just noise, they're telling you stuff that can be improved in the package β€” and ngl, in most cases those improvements concern the upstream sources directly 🫢. here they are, ordered from most important to least important, so you know what to panic about first:

🫢 Warnings 🫢

  • symbol sym used by binary found in none of the libraries β€” the symbol in question wasn't found in any of the libraries linked with the binary 😭 the binary is almost certainly a library itself, and it needs to be linked with an additional library during the build (that's the linker's -llibrary option, iykyk).
  • binary contains an unresolvable reference to symbol sym: it's probably a plugin β€” same situation, symbol wasn't found in the libraries linked with the binary. but this time the binary is most likely a plugin, and the symbol is probably provided by the program that loads this plugin 🧩. in theory a plugin doesn't have any SONAME, but this binary does have one, so it couldn't be clearly identified as a plugin. however β€” if the binary is stored in a non-public directory, that's a strong indication it's not a normal shared library πŸ‘‘. if it really is a plugin, go ahead and disregard this warning. but bestie, there's always the possibility that it's a real library and that the programs linking to it are using an RPATH so the dynamic loader finds it β€” and in that case the library is broken and needs to be fixed πŸ’€.
  • package could avoid a useless dependency if binary was not linked against library (it uses none of the library's symbols) β€” none of the binaries linked with library use any of the symbols that library provides πŸ™ˆ fix all the binaries and you'd avoid the dependency associated with this library (unless the same dependency also gets generated by another library that's actually used, no cap).
  • package could avoid a useless dependency if binaries were not linked against library (they use none of the library's symbols) β€” exactly the same as the warning above, but for multiple binaries ✨.
  • binary should not be linked against library (it uses none of the library's symbols) β€” the binary is linked to a library it doesn't need. it's not a problem exactly, but you can get some small performance improvements in binary load time by not linking this library to this binary 🌸. this warning checks the same information as the previous one, except it does it for each binary individually instead of doing the check globally across all binaries analyzed πŸ‘‘

😭 Errors 😭

dpkg-shlibdeps will fail if it can't find a public library used by a binary, or if that library has no associated dependency information (either a shlibs file or a symbols file) πŸ’€. quick definitions so we're on the same page: a public library has a SONAME and is versioned (libsomething.so.X). a private library (like a plugin) should not have a SONAME and doesn't need to be versioned πŸŽ€.

  • couldn't find library library-soname needed by binary (its RPATH is 'rpath') β€” the binary uses a library called library-soname, but dpkg-shlibdeps could not find it anywhere 😭. here's the whole search order it builds up: directories listed in the RPATH of the binary, directories added by the -l option, directories listed in the LD_LIBRARY_PATH environment variable, cross multiarch directories (ex. /lib/arm64-linux-gnu, /usr/lib/arm64-linux-gnu), standard public directories (/lib, /usr/lib), directories listed in /etc/ld.so.conf, and obsolete multilib directories (/lib32, /usr/lib32, /lib64, /usr/lib64) πŸ”. then it checks those directories in the package's build tree of the binary being analyzed, in the packages' build trees indicated with the -S command-line option, in other packages' build trees that contains a DEBIAN/shlibs or DEBIAN/symbols file, and finally in the root directory. if the library isn't in any of those, you get this error. periodt.
    • if the library that wasn't found lives in a private directory of the same package, you want to add that directory with -l πŸ’…. if it's in another binary package being built, make sure that the shlibs/symbols file of that package is already created, and that -l contains the appropriate directory if it's also in a private directory 🫢.
  • no dependency information found for library-file (used by binary) β€” the library needed by binary was found by dpkg-shlibdeps in library-file, but dpkg-shlibdeps couldn't find any dependency information for it πŸ™ˆ. to figure out the dependency it tried to map the library to a Debian package with the help of dpkg -S library-file. then it checked the corresponding shlibs and symbols files in /var/lib/dpkg/info/, and in the various package's build trees (debian/*/DEBIAN/) πŸ”Ž.
    • this failure can be caused by a bad or missing shlibs or symbols file in the package of the library 😀. it might also happen if the library is built within the same source package and the shlibs files has not yet been created β€” in which case you must fix debian/rules to create the shlibs before calling dpkg-shlibdeps. a bad RPATH can also lead to the library being found under a non-canonical name (example: /usr/lib/openoffice.org/../lib/libssl.so.0.9.8 instead of /usr/lib/libssl.so.0.9.8) that's not associated to any package. dpkg-shlibdeps tries to work around this by trying to fallback on a canonical name (using realpath(3)) but it might not always work 😭. it's always best to clean up the RPATH of the binary to avoid problems, fr fr.
    • pro move 🧚: calling dpkg-shlibdeps in verbose mode (-v) gives you much more information about where it tried to find the dependency information. super useful if you're sitting there like "why is it giving me this error??"

✨ SEE ALSO ✨

go read these next, bestie, they're iconic:


and that's the whole page, you ate that πŸ’… this was dpkg-shlibdeps(1) from version 1.23.11-dirty, dated 2026-09-09 β€” go forth and slay your dependency graph, mwah πŸŽ€πŸ’–

πŸ“¦ where this page comes from