Pdebuild-cross is a tool for cross-building packages from an existing distribution. It is available in Debian squeeze and Ubuntu Maverick.

It uses the pbuilder mechanisms to run inside a chroot, and has the same advantages and disadvantages:

  • The build starts with a fresh chroot every time so results are consistent, and you can tell when dependencies are missing.
  • There is a time overhead for the unpacking and dependency installation (which can be mitigated by use of apt caches and cowbuilder).
  • Because the 'make clean' part is done outside the build chroot, any dependencies needed for that must be installed on the host system.

It is not the right tool to use if you want to cross-build a whole set of packages together, e.g to build a set of packages targeting a new flavour of optimisation (e.g you have a repository compiled for v7 but want to rebuild targetting v5). For that you should use xdeb. See UsingXdeb

For an overview of Cross-building (Issues, tools, options, how it is suppose to work) see CrossBuilding

How it works

pdebuild-cross does everything in a pbuilder-managed chroot. The chroot is a native chroot, containing a minimal system and the cross-tools along with build-essential packages. This chroot is made by 'pdebuild-cross-create' (which uses multistrap to do the chroot creation).

When you build a package with pdebuild-cross things operate the same way as 'debuild' except that some extra hook-scripts are run to install cross-dependencies as well as native dependencies, and to run dpkg-buildpackage -a<targetarch> instead of plain dpkg-buildpackage. The current cross-dependency-satisfaction tool is 'xapt' which is simple-minded but effective. Using other tools here such as xdeb would be interesting.

Pdebuild-cross-create uses multistrap rather than debootstrap in order to allow for the case when you want to use a base system from one repository, and cross-toolchains from another. This is quite common, and deboostrap does not support this mode (you have to manually install the cross-tools to the chroot).

The config used is specified in /etc/pdebuild-cross/pdebuild-cross.rc. This specifies the default target architecture, DEBBUILOPTS, mulstrap config used to make the build chroot, filename of resulting tarball, hook dir to run scripts from, apt cache file to use, and dirs to use for mounting builds and saving results.

The default chroot sources used for maverick are in /usr/share/multistrap/ubuntu/armel.conf. Change the setting MULTISTRAPFILE=/usr/share/multistrap/ubuntu/armel.conf in /etc/pdebuild-cross/pdebuild-cross.rc if you want to use a different base chroot. The most common reason to change this is that you want use a different cross-compiler from the one supplied in Ubuntu maverick. Man multistrap explains the syntax of the cascading config files.

How to use

First create a chroot with

sudo pdebuild-cross-create -a armel

This will make a native (build-arch) maverick chroot (in /var/pdebuild-cross/pdebuild-cross.tgz) including the maverick armel-cross-toolchains

then download the sources you want to build apt-get source package (you will need a suitable deb-src line in your config, such as )

Then build the source in the usual way by changing into the source dir and issuing the build command:

cd <package>-<version>

The results will appear in /var/pdebuild-cross/result if the build is successful. That's essentially it. Nice and simple.

More details of use

Because pbuilder does 'make clean' outside the build chroot in order to prepare a clean source package for building, any dependencies needed for that must be installed on the host system. Here is a last of the ones noted so far which will cover a wide range of packages. Please add others you find:

apt-get install cdbs quilt dpatch dh-autoreconf gnome-pkg-tools dh-apport hardening-includes mozilla-devscripts


Needed to 'make clean' for package




anything from gnome



If you need to go into the chroot to test something then the appropriate pbuilder command is:

sudo pbuilder login --configfile /etc/pdebuild-cross/pdebuild-cross.rc

If you want to go into the chroot to change something permanently then do:

sudo pbuilder login --save-after-login --configfile /etc/pdebuild-cross/pdebuild-cross.rc

bear in mind that if you do apt-get update in the chroot and then save that status the chroot will have got about 40Mb bigger than it was and those (soon out of date) packages files will be unpacked every time.

If you want to go into the chroot to test something, without saving any changes to the base chroot then do:

sudo pbuilder login --configfile /etc/pdebuild-cross/pdebuild-cross.rc

Note that either of these last two pbuilder login commands will not run all the hook scripts which install dependencies and cross-dependencies.

To update your cross-chroot environment to latest available packages run

sudo pdebuild-cross-update

On a stable release this is generally not necessary.


Platform/DevPlatform/CrossCompile/UsingPdebuildCross (last modified 2011-03-15 21:04:36)