dpkg-shlibdeps(1) dpkg suite dpkg-shlibdeps(1)
dpkg-shlibdeps - generate shared library substvar dependencies
| Use Case | Command | Description |
|---|---|---|
| Analyze a single executable | dpkg-shlibdeps -e ./executable |
Compute shared library dependencies for a given executable. |
| Specify a custom dependency field | dpkg-shlibdeps -d Pre-Depends -e ./executable |
Add dependencies to the Pre-Depends field instead of the default Depends. |
| Use a local shlibs override | dpkg-shlibdeps -L ./my-shlibs.local -e ./executable |
Override shlibs information with a custom local file. |
| Exclude a package from dependencies | dpkg-shlibdeps -x libfoo -e ./executable |
Avoid self-dependencies when the package provides its own libraries. |
| Print dependencies to stdout | dpkg-shlibdeps -O -e ./executable |
Output substitution variable settings instead of modifying debian/substvars. |
dpkg-shlibdeps [option...] [-e] executable [option...]
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.
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.
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):
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).
As a safe-guard measure, a symbols file can provide a Build-Depends-Package 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.
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.
The dependencies for a library are looked up in several places. The first file providing information for the library of interest is used:
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).
dpkg-shlibdeps interprets non-option arguments as executable names, just as if they’d been supplied as -eexecutable.
-eexecutableInclude dependencies appropriate for the shared libraries required by executable. This option can be used multiple times.
-ldirectoryPrepend directory to the list of directories to search for private shared libraries (since dpkg 1.17.0). This option can be used multiple times.
Note: 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.
-ddependency-fieldAdd 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.
-pvarname-prefixStart 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, since dpkg 1.17.2), rather than being added to the substitution variables file (debian/substvars by default).
-ttypePrefer 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-fileRead overriding shared library dependency information from local-shlibs-file instead of debian/shlibs.local.
-Tsubstvars-fileWrite substitution variables in substvars-file; the default is debian/substvars.
-vEnable verbose mode (since dpkg 1.14.8). Numerous messages are displayed to explain what dpkg-shlibdeps does.
-xpackageExclude the package from the generated dependencies (since dpkg 1.14.8). 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.
-Spackage-build-dirLook into package-build-dir first when trying to find a library (since dpkg 1.14.15). 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.
-Ipackage-build-dirIgnore package-build-dir when looking for shlibs, symbols, and shared library files (since dpkg 1.18.5). You can use this option multiple times.
--ignore-missing-infoDo not fail if dependency information can’t be found for a shared library (since dpkg 1.14.8). 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.
--warnings=valuevalue is a bit field defining the set of warnings that can be emitted by dpkg-shlibdeps (since dpkg 1.14.17). Bit 0 (value=1) enables the warning “symbol sym used by binary found in none of the libraries”, bit 1 (value=2) enables the warning “package could avoid a useless dependency” and bit 2 (value=4) enables the warning “binary should not be linked against library”. The default value is 3: the first two warnings are active by default, the last one is not. Set value to 7 if you want all warnings to be active.
--admindir=dirChange the location of the dpkg database (since dpkg 1.14.0). The default location is /var/lib/dpkg.
-?, --helpShow the usage message and exit.
--versionShow the version and exit.
DPKG_COLORSSets the color mode (since dpkg 1.18.5). The currently accepted values are: auto (default), always and never.
DPKG_NLSIf set, it will be used to decide whether to activate Native Language Support, also known as internationalization (or i18n) support (since dpkg 1.19.0). The accepted values are: 0 and 1 (default).
Since dpkg-shlibdeps analyzes the set of symbols used by each binary of the generated package, it is able to emit warnings in several cases. They inform you of things that can be improved in the package. In most cases, those improvements concern the upstream sources directly. By order of decreasing importance, here are the various warnings that you can encounter:
dpkg-shlibdeps will fail if it can’t find a public library used by a binary or if this library has no associated dependency information (either shlibs file or symbols file). 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.
deb-shlibs(5), deb-symbols(5), dpkg-gensymbols(1).
1.21.1 2025-09-09 dpkg-shlibdeps(1)
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-01 02:11 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)