Installing QEMU on Mac OS X Yosemite

QEMU is an open source computer emulator. Here I describe how I installed QEMU on Mac OS X Yosemite.

My goal was to learn more about building QEMU, and to boot Linux on QEMU.

I downloaded and unpacked QEMU 2.3.0 (this was the latest stable release at the date I did the download), by doing

tar xvjf qemu-2.3.0.tar.bz2
cd qemu-2.3.0

Then, based on my earlier experiences, 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

ERROR: glib-2.22 gthread-2.0 is required to compile QEMU

I tried my previous approach, where I installed the required glib version using sudo port install. I used the command

sudo port install glib-2.2

which resulted in

Warning: port definitions are more than two weeks old, consider using selfupdate
Error: Port glib-2.2 not found

I followed this advice, and did

sudo port selfupdate

but that led me into new troubles, with error messages telling me that my Xcode Command Line Tools were most likely not installed. I tried to install these tools but without luck

I was about to give up when I stumbled upon rudix. This turned out to be an attractive solution! I read at the rudix page that I should do

sudo python install rudix

Then, from the rudix glib page, I learned that I should do

sudo rudix install glib

I did as told, and now the configure command

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

succeeded. I followed it up by building, using make, but that did not succeed.

I looked at the build errors, which led me to this page with advice, which told me to add make targets, resulting in lines like

scaling_helpers_test_OBJECTS = scaling-helpers-test.$(OBJEXT) utils.$(OBJEXT)

in the file


where the last target had to be added by me. A similar change, in the same Makefile, was required, and resulted in the modified line

region_test_OBJECTS = region-test.$(OBJEXT) utils.$(OBJEXT)

The errors went away, but a new link error remained. The error printout was

LINK qemu-ga
ld: library not found for -lintl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [qemu-ga] Error 1

I found this page with advice on how to solve it using brew (which was not applicable to my problem).

However, since I now had my rudix package, I chose instead to do

sudo rudix install gettext

This resulted in a successful build, and I could then also do make install to install my new QEMU.

Now I wanted to boot Linux! I looked at the QEMU Testing page, and decided to download and unpack a Linux image by doing

bzip2 -d linux-0.2.img.bz2

A Linux boot could then be done, by starting QEMU with the downloaded Linux image as argument, as

qemu-system-i386 -hda linux-0.2.img