Cross Compiling Qemu on Ubuntu - the multiarch way

This document demonstrates howto cross-build qemu-linaro using multiarch libraries.

Preparing the multiarch chroot

For testing, it is a good idea to have a chroot instread of potentially messing your desktop system

sudo debootstrap --variant=buildd raring /srv/raring
sudo chroot /srv/raring
mount -t proc proc /proc
dpkg --add-architecture armhf 

Set up the /etc/apt/sources.list: (use arch=amd64 if you made and x86_64 chroot)

deb [arch=i386] raring main universe
deb [arch=armhf] raring main universe
deb-src raring main universe

In /etc/apt/apt.conf.d/10local disable installing recommends:

APT::Install-Recommends "0";
APT::Install-Suggests "0";

Create a /usr/sbin/policy-rc.d file to prevent daemons to start in the chroot

echo "exit 101" > /usr/sbin/policy-rc.d
chmod a+x /usr/sbin/policy-rc.d

Install toolchain and essentials

apt-get update
apt-get install g++-arm-linux-gnueabihf build-essential 
cd /usr/bin
ln -s /usr/share/pkg-config-crosswrapper arm-linux-gnueabihf-pkg-config

Install in build-dependencies for qemu

apt-get build-dep -aarmhf qemu
apt-get install python:i386 python2.7:i386 python2.7-minimal:i386 device-tree-compiled:i386

building a debian package

apt-get source qemu
cd qemu*

Add the following lines to debian/rules

# Cross compiling support
       common_configure_opts  += --cross-prefix=$(DEB_HOST_GNU_TYPE)-

And proceed to build:

export DEB_BUILD_OPTIONS=parallel=3 #if you have multicore machine
dpkg-buildpackage -d -b -B -aarmhf 2>&1|tee ../qemu.log

building a git snapshot

Pull the sources from git:

$ git://
$ cd qemu

Build with appropriate configure flags (use make -j3 if on multicore machine):

$ mkdir arm-build
$ cd arm-build
$ ../configure --cross-prefix=arm-linux-gnueabihf- --target-list=arm-softmmu --enable-kvm
$ make
$ sudo make install DESTDIR=/wherever/you/want #replace 

Work in progress

  • qemu packaging changes needed to make it cross-build out of box
  • device-tree-compiler packaging needs multiarch:foreign


Platform/DevPlatform/CrossCompile/QemuCrossCompile (last modified 2013-08-23 11:48:42)