Installing QEMU

QEMU is an open source computer emulator. Here I describe how I installed QEMU on Linux and on Mac Mountain Lion.

My goal was to create a simulator for machines with ARM architecture and for machines with x86 architecture.

Updates to this post

  • July 15, 2013 – changed the section on Ubuntu Linux to cover QEMU 1.5.1 instead of QEMU 1.2.0.

Ubuntu Linux

Starting from the QEMU home page I navigated to the download page. From there I downloaded the file

qemu-1.5.1.tar.bz2

I unpacked the file, and navigated to the directory created during the unpacking, using the commands

tar xvjf qemu-1.5.1.tar.bz2
cd qemu-1.5.1

As a preparation, I needed to update my Ubuntu 13.04 installation. It turned out that the following installations were needed:

sudo apt-get install zlib1g-dev
sudo apt-get install libglib2.0
sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install libsdl-console
sudo apt-get install libsdl-console-dev

I could then configure QEMU, using the command

./configure --target-list=i386-softmmu,arm-softmmu,x86_64-softmmu --disable-vnc --enable-sdl

I could then build and install, using

make
sudo make install

I could then use QEMU, for simulation of an ARM computer, e.g. as

qemu-system-arm -M realview-pb-a8 -nographic -kernel prog_arm_rpb_a8.elf

and simulation of an x86 computer, e.g. as

qemu-system-x86_64 -kernel prog_x86_grub_target.elf

Problems encountered – I had some trouble before realizing which packages to add to Ubuntu in order to get QEMU to build. The first thing that happened was that the configure command failed, with

ERROR: zlib check failed
Make sure to have the zlib libs and headers installed.

which, after some searching, led me to install zlib as

sudo apt-get install zlib1g-dev

Then I got a message I recognized from my installation of QEMU on Mac, saying that

ERROR: glib-2.12 required to compile QEMU

which, again after some searching, led to the installation of glib as

sudo apt-get install libglib2.0

Configure was now happy but make was not. The make command gave an error, as

(cd /home/ola/Downloads/qemu-1.5.1/pixman; autoreconf -v --install)
/bin/sh: autoreconf: command not found
make: *** [/home/ola/Downloads/qemu-1.5.1/pixman/configure] Error 127

Trying the command autoreconf, as

ola@ola-Aspire-S3-391:~/Downloads/qemu-1.5.1$ autoreconf
The program 'autoreconf' can be found in the following packages:
* autoconf

led to the installation of autoconf, as

sudo apt-get install autoconf

An error telling me to install libtool then appeared, as

../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
configure.ac:552: the top level
configure.ac:75: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
make: *** [/home/ola/Downloads/qemu-1.5.1/pixman/configure] Error 1
make: *** Deleting file `/home/ola/Downloads/qemu-1.5.1/pixman/configure'

which, by help from Erik Rull, led me to the installation of libtool, as

sudo apt-get install libtool

Now everything built, and I could also do an installation of QEMU, as

sudo make install

The ARM simulation worked fine, but there was no screen in the x86 simulation. I guessed that I needed also SDL for this purpose, and after the installation of sdl, as

sudo apt-get install libsdl-console
sudo apt-get install libsdl-console-dev

I could see a console, and the long-awaited “Hello, world”-message from my program.

Linux

I downloaded and unpacked QEMU in the same way as described above for Ubuntu Linux.

Then, since I was not root on the machine, I used the configure command

./configure --prefix=/nobackup/local/prog/qemu --target-list=i386-softmmu,arm-softmmu,x86_64-softmmu --disable-vnc

followed by commands for build and installation, as

make
make install

I also added the following changes

export PATH=/nobackup/local/prog/qemu/bin:$PATH

to my setup script, where I also set up other environment variables.

I could then use QEMU, for simulation of an ARM computer, e.g. as

qemu-system-arm -M realview-pb-a8 -nographic -kernel prog_arm_rpb_a8.bin

Mac Mountain Lion

I downloaded and unpacked QEMU 1.2.0 in the same way as described above for Ubuntu Linux.

Then, based on information from Ruben Schade, I used the configure command

./configure --enable-cocoa --target-list=i386-softmmu,arm-softmmu,x86_64-softmmu --disable-vnc

This command generated an error, telling me that “glib-2.12” was “required to compile QEMU”. I searched for this error, and after having read at this MacPorts-related page, I ended up doing

sudo port install glib-2.12
sudo port selfupdate
sudo port upgrade outdated

which, as a result, made it possible to redo the configure command as decribed above.

I then built QEMU, which succeeded but with several warnings, and installed it, using

make
sudo make install

I could now use QEMU, for simulation of an ARM computer, e.g. as

qemu-system-arm -M realview-pb-a8 -nographic -kernel prog_arm_rpb_a8.bin

Advertisements

About Ola
Writer of fiction and non-fiction, published the suspense novel Prevention - creating Books with Views - with books on programming and embedded systems - http://my.bookbaby.com/book/prevention

13 Responses to Installing QEMU

  1. dnlopes says:

    Good post. I followed your instructions and it all worked just fine

  2. Pingback: Qemu and simple Bootloader | misrapankaj

  3. Ziffel says:

    Wow, really great article, thank you so much!!! I’ve tried to install QEMU for 7 hours by now and it was like a search in deep fog – but then I discovered your blog where you describe exactly the same problems as mine! Everything is working fine now with your instructions 🙂

    • Ola says:

      Good to hear! Thanks for commenting!

    • i am using ubuntu 16.04 ,i want to install qemu on my system,while following your steps,
      i got an error (after configure)make command.that error is

      make all-recursive
      Making all in pixman
      make all-am
      make[4]: Nothing to be done for ‘all-am’.
      Making all in test
      make[3]: Nothing to be done for ‘all’.
      make[3]: Nothing to be done for ‘all-am’.
      LEX convert-dtsv0-lexer.lex.c
      make[1]: flex: Command not found
      BISON dtc-parser.tab.c
      make[1]: bison: Command not found
      LEX dtc-lexer.lex.c
      make[1]: flex: Command not found
      CHK version_gen.h
      AR libfdt/libfdt.a
      ar: two different operation options specified
      Makefile:234: recipe for target ‘libfdt/libfdt.a’ failed
      make[1]: *** [libfdt/libfdt.a] Error 1
      Makefile:152: recipe for target ‘subdir-dtc’ failed
      make: *** [subdir-dtc] Error 2
      root@My–pc:/home/chandru/qemu-1.5.1# ^C
      root@My–pc:/home/chandru/qemu-1.5.1#

      give a solution to me

  4. i followed all instructions ,but at last, giving command make, i got a error
    that error i posted,please give a solution to this error.

    make all-recursive
    Making all in pixman
    make all-am
    make[4]: Nothing to be done for ‘all-am’.
    Making all in test
    make[3]: Nothing to be done for ‘all’.
    make[3]: Nothing to be done for ‘all-am’.
    LEX convert-dtsv0-lexer.lex.c
    make[1]: flex: Command not found
    BISON dtc-parser.tab.c
    make[1]: bison: Command not found
    LEX dtc-lexer.lex.c
    make[1]: flex: Command not found
    CHK version_gen.h
    AR libfdt/libfdt.a
    ar: two different operation options specified
    Makefile:234: recipe for target ‘libfdt/libfdt.a’ failed
    make[1]: *** [libfdt/libfdt.a] Error 1
    Makefile:152: recipe for target ‘subdir-dtc’ failed
    make: *** [subdir-dtc] Error 2
    root@My–pc:/home/chandru/qemu-1.5.1# ^C
    root@My–pc:/home/chandru/qemu-1.5.1#

    And i am using ubuntu 16.04 LTS,please give the solution or give the which way i have to follow to install qemu on ubuntu 16.04.

  5. Ola says:

    It looks like you are missing flex and bison.

    Perhaps you can install them by doing

    sudo apt-get install flex bison

    and then try again?

  6. swati says:

    I tried, sudo apt-get install flex bison

    Still getting—-

    GEN config-host.h
    make all-recursive
    Making all in pixman
    make[3]: Nothing to be done for `all’.
    Making all in demos
    make[3]: Nothing to be done for `all’.
    Making all in test
    make[3]: Nothing to be done for `all’.
    make: *** [subdir-dtc] Error 2

  7. swati says:

    I tried sudo apt-get install flex bison also,

    Still getting —

    make all-recursive
    Making all in pixman
    make[3]: Nothing to be done for `all’.
    Making all in demos
    make[3]: Nothing to be done for `all’.
    Making all in test
    make[3]: Nothing to be done for `all’.
    make: *** [subdir-dtc] Error 2

  8. Ola says:

    I have not seen this however I have not tried on Ubuntu 16.04 yet. Perhaps a long shot but this one may help? http://askubuntu.com/questions/424329/error-trying-to-compile-qemu-from-source

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: