Compile QEMU from source and make a Debian package with CheckInstall

By | December 15, 2015

The following post was graciously contributed by guest author, Ruben F

I was only going to do this on my own PC but then I thought that other people may want to do the same. As of today, I’m using Ubuntu (14.04) Trusty LTS.

Uname -a

3.13.0-68-generic #111-Ubuntu SMP Fri Nov 6 18:17:06 UTC 2015 x86_64 x86_64 x86_64


Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 12
On-line CPU(s) list: 0-11
Thread(s) per core: 2
Core(s) per socket: 6
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 63
Stepping: 2
CPU MHz: 1200.000
BogoMIPS: 6596.31
Virtualization: VT-x

First off Ubuntu offers qemu for Trusty in its repositories. Only problem is that its version 2.0.0 but it should work for most instances. I simply wanted to have the latest version and, more importantly, control my installation. At the time of me writing this, qemu 2.5.0-rc1 is the latest version offered at

Getting CHECKINSTALL installed

What is checkinstall? Sometimes distro package managers lack or do not have the latest version for whatever application you’re interested in. What checkinstall is – its for those users that want to either create a .deb (or .rpm) to easily install and, possibly, use on a separate system or to have a way to uninstall 3rd party applications… Now, I know what you’re thinking. How can building a binary on one system be ported to another and still be fast as building it for that original system. I doubt it’ll be as ‘fast’ but I have yet to use the .rpms/.debs I’ve created on one system on another system so I don’t have any personal examples. I just figured I would still be able to dpkg -i it on another system. Bottom line is that checkinstall allows your package manager to be involved when 3rd party software is introduced on your system. Which is a good thing.

Prep for checkinstall

sudo aptitude update ; sudo aptitude install build-essential git libtool pkg-config intltool-debian checkinstall -y

If I spelled everything correctly, this will download all the proper compiling software needed to build binaries as well as checkinstall itself. Ubuntu offers the latest version of checkinstall in its repositories (at the time of me writing this).

Give yourself ownership of the /usr/local/src/ directory to keep your source files. You can use any directory you want so don’t feel like you need to follow exactly everything I did. Use mkdir if the directory doesn’t exist.

sudo chown $USER /usr/local/src

cd /usr/local/src

Getting QEMU compiled

Why use qemu? VirtualBox is the go to choice for almost everyone using Linux. A small percentage are using VMWare and even smaller are using straight kvm/xen. Virtualbox, in particular, works great on Linux and it keeps getting better with every new iteration. I have it installed on my notebook (with Linux Mint)since I don’t want to spend too much time fooling around getting software configured – I simply want something that works right away. On my desktop (yes, I have one), its different. I use the desktop for intermediate/advanced projects since it offers more power/memory.

In your /usr/local/src directory

git clone git://

Once thats done downloading

mkdir qemu/{build,debug} ; cd qemu/debug


Once thats done scroll up and notice all the “no” you see. We’re going to change a lot of those options to “yes.” Generally, its a good idea to have as many options available to qemu as possible. This also depends on system to system so in the next couple of steps you do what you feel is best for your system.

You’ll need to download more packages in order to satisfy qemu’s needs

sudo aptitude install libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libaio-dev libbluetooth-dev libbrlapi-dev libbz2-dev  libcap-dev libcap-ng-dev libcurl4-gnutls-dev libgtk-3-dev libibverbs-dev libjpeg8-dev libncurses5-dev libnuma-dev librbd-dev librdmacm-dev libsasl2-dev libsdl1.2-dev libseccomp-dev libsnappy-dev libssh2-1-dev libvde-dev libvdeplug-dev libvte-2.90-dev libxen-dev liblzo2-dev valgrind xfslibs-dev

aptitude may ask you a few questions (replacing config files/updating blah blah blah) do what’s best for your environment.

Testing QEMU

../configure –enable-debug

You should see a lot of “yes” now. Pay attention to “host cpu” and “kvm support”

cd x86_64-softmmu

(or i386 if you’re on a 32-bit system)

wget (the URL may change in time. Just download the latest test img from qemu)

bunzip2 linux-0.2.img.bz2

./qemu-system-x86_64 -L pc-bios

(this tests to see if your default settings work. No flags)

./qemu-system-x86_64 -cpu host –enable-kvm -L pc-bios

(uses kvm to launch bios)

./qemu-system-x86_64 -cpu host –enable-kvm -display gtk (or sdl) linux-0.2.img

(launches the Linux imagine using kvm and uses gtk/sdl for display. Doesn’t technically make use of gtk without using a GNU desktop environment but you will receive an error if you cannot use the gtk/sdl option)

Once you have everything you want tested, you’ll need to install qemu on your system. You can delete the Linux imagine or just keep it around for future tests. I suggest:

mv linux-0.2.img ~

Installing QEMU [via checkinstall]

navigate to the qemu/build directory that you made ealier.

cd ../../build

I used the following command since I was only interested in 32/64 CISC architecture.

../configure –target-list=i386-linux-user,i386-softmmu,x86_64-linux-user,x86_64-softmmu –enable-system –enable-sdl –enable-gtk –enable-vte –enable-kvm –enable-bzip2 –enable-libssh2 –enable-linux-user –enable-docs –enable-gnutls –enable-nettle –enable-curses –enable-modules –enable-virtfs –enable-curl –enable-fdt –enable-rdma –enable-uuid –enable-vde –enable-linux-aio –enable-cap-ng –enable-attr –enable-vhost-net –enable-spice –enable-rbd –enable-libiscsi –enable-libnfs –enable-smartcard –enable-libusb –enable-usb-redir –enable-lzo –enable-snappy –enable-seccomp –enable-coroutine-pool –enable-glusterfs –enable-tpm –enable-vhdx –enable-numa –enable-tcmalloc

(this website might have converged the two “-” dashes into a single line. You’ll see an error code if there is a single line in front of the ‘enable’)

Will I ever utilize all these options? Probably not but at least they’re be available if I need them. I would suggest at least doing an –enable-gtk (or sdl) –enable-vte –enable-kvm –enable-libssh2 –enable-gnutls. Typically configure/make will try to enable everything that it ‘sees’ available. I added the all those –enable to ensure that it did.

If you run into dependency issues then you’ll have to download the specific package(s) via aptitude or you’ll have to go online to retrieve it/them (if Ubuntu’s version is too old). I downloaded a several from and for my Ubuntu desktop. They worked fine. Moreover, some of the packages are named differently than what the “ERROR” output is asking for. You’ll probably have to do a combination of aptitude search and aptitude versions to track down the dependencies you’re looking for.

make -j6

(since I have 6 cpu cores)

sudo checkinstall -D

Checkinstall will ask you a series of questions. Eventually you will need to change the following values:

name: qemu (or qemu2.5)

version: 2.5.0-rc1 (its really 2.4.9)

checkinstall will make and install a .deb for you.

ll *.deb

(you’ll see the new .deb. Move it somewhere else if you want to)


(or cd ~ if that doesn’t take you home)

qemu-system-x86_64 –version

(not quite the version they advertise, right?)

qemu-system-x86_64 -cpu host –enable-kvm -display gtk linux-0.2.img

You’ll have to set your qemu flags on your own depending on what you’re doing (i.e. installing from an ISO, running a virtualbox imagine, setting VGA flags, etc, etc)

I recommend redirecting the help screen to a file on your desktop. I even printed mine out so I can easily reference the qemu flags/options.

congrats you have qemu compiled and installed !

One thought on “Compile QEMU from source and make a Debian package with CheckInstall

  1. Marsha

    It’s nearly impossible to find knowledgeable people in this particular subject,
    however, you sound like you know what you’re talking about!


Comments are closed.