dpkg-buildapi - Linux


dpkg-buildapi generates a source distribution of the API headers and description files of a Debian package. It also transforms the package it documents into a library, i.e. it generates a header file that declares the functions the library exports.


dpkg-buildapi [OPTION...] PACKAGE [DESTDIR]


  • -a, –architecture=ARCH
    Specify the architecture for the source distribution.

  • -c, –compile
    Try to compile the library (also implies --target=installed).

  • -d, –debug=LEVEL
    Enable debug messages.

  • -f, –filelist=FILE
    Read package file list from FILE instead of detecting it from package.

  • -p, –target=TYPE
    Target to build for:

    • package – as a Debian package (default)
    • installed – as a standalone installed package
    • library – as an installed library
  • -V, –version
    Display the version of dpkg-buildapi.


Generate a library header for the package libfoo:

dpkg-buildapi -p library libfoo

Generate a source distribution:

dpkg-buildapi -p package libfoo

Common Issues

Error: "dpkg-buildapi: cannot find package information for libfoo"

Solution: Ensure that the package is properly installed and its information is available in the Debian package database.


dpkg-buildapi output can be used as input for other Debian packaging tools, such as dh_installdeb for creating Debian packages or dh_makeshlibs for generating shared library packaging files.

Related Commands

  • dh_make – compiles and installs a Debian package
  • dpkg-deb – utility to manipulate Debian packages
  • dh_installdeb – helper for dh to install Debian packages