Building qemu for a change

I’ve played with qemu on and off for as long as I can remember (and I remember struggling with Bochs on DEC OSF/1). These days life is Vista orientated for work reasons and by and by I’ve ended up with win32 as my main development environment, even when I work on GTK+ code (the beauty of cross platform libraries I guess).

Nowadays we are blessed with lots of good virtualisation software (VirtualPC, VMWare, VirtualBox). While I have a regular rotation of VirtualBox setups, I thought I could see how well qemu was going, but it seems that the win32 binaries are a bit on the stale side (0.9.0 vs 0.10.6). So lets try to build it under mingw/msys….


Download and install zlib.

$ tar zxf ../Downloads/zlib-1.2.3.tar.gz
$ cd zlib-1.2.3
$ make -f win32/Makefile.gcc
$ cp zlib.h zconf.h /usr/include
$ cp libz.a /usr/lib

Download and install SDL

$ tar zxf ../Downloads/SDL-1.2.13.tar.gz
$ cd SDL-1.2.13
$ ./configure --prefix=/usr
$ make

Which only gets to:

windres ./src/main/win32/version.rc build/version.o
/bin/sh ./libtool --mode=link gcc -o build/ build/SDL.lo build/SDL_error.lo build/SDL_fatal.lo build/SDL_audio.lo build/SDL_audiocvt.lo build/SDL_audiodev.lo build/SDL_mixer.lo build/SDL_mixer_MMX.lo build/SDL_mixer_MMX_VC.lo build/SDL_mixer_m68k.lo build/SDL_wave.lo build/SDL_cdrom.lo build/SDL_cpuinfo.lo build/SDL_active.lo build/SDL_events.lo build/SDL_expose.lo build/SDL_keyboard.lo build/SDL_mouse.lo build/SDL_quit.lo build/SDL_resize.lo build/SDL_rwops.lo build/SDL_getenv.lo build/SDL_iconv.lo build/SDL_malloc.lo build/SDL_qsort.lo build/SDL_stdlib.lo build/SDL_string.lo build/SDL_thread.lo build/SDL_timer.lo build/SDL_RLEaccel.lo build/SDL_blit.lo build/SDL_blit_0.lo build/SDL_blit_1.lo build/SDL_blit_A.lo build/SDL_blit_N.lo build/SDL_bmp.lo build/SDL_cursor.lo build/SDL_gamma.lo build/SDL_pixels.lo build/SDL_stretch.lo build/SDL_surface.lo build/SDL_video.lo build/SDL_yuv.lo build/SDL_yuv_mmx.lo build/SDL_yuv_sw.lo build/SDL_joystick.lo build/SDL_nullevents.lo build/SDL_nullmouse.lo build/SDL_nullvideo.lo build/SDL_diskaudio.lo build/SDL_dummyaudio.lo build/SDL_sysevents.lo build/SDL_sysmouse.lo build/SDL_syswm.lo build/SDL_wingl.lo build/SDL_dibevents.lo build/SDL_dibvideo.lo build/SDL_dibaudio.lo build/SDL_mmjoystick.lo build/SDL_syscdrom.lo build/SDL_sysmutex.lo build/SDL_syssem.lo build/SDL_systhread.lo build/SDL_syscond.lo build/SDL_systimer.lo build/SDL_sysloadso.lo build/version.o  -lm -luser32 -lgdi32 -lwinmm -no-undefined -rpath /usr/lib -release 1.2 -version-info 11:2:11
libtool: link: cannot build libtool library `build/' from non-libtool objects on this host: build/version.o
make: *** [build/] Error 1

Then we need to use the magic pointed to here:

$ ./libtool --tag=RC --mode=compile windres src/main/win32/version.rc -o build/version.o
then edit Makefile and change “$(objects)/version.o” to “$(objects)/version.lo”

and finally we can do:

$ make
$ make install

Now for qemu

$ tar zxf ../Downloads/qemu-0.10.5.tar.gz
$ cd qemu-0.10.5
$ ./configure --prefix=/c/apps/qemu-0.10.5 --disable-kvm
Error: zlib check failed
Make sure to have the zlib libs and headers installed.

I couldn’t resolve this in a nice way… I just edited the configure file to add OS_FLAGS to the MINGW32 section:

OS_CFLAGS="-I/usr/include -L/usr/lib"
if [ "$cpu" = "i386" ] ; then


$ ./configure --prefix=/c/apps/qemu-0.10.5 --disable-kvm
$ make
c:/apps/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lz
collect2: ld returned 1 exit status
make: *** [qemu-img.exe] Error 1

It seems that zlib still isn’t found. So to be expedient, add it to the Makefile:





and we are away…

$ make
$ make install

Almost there…

$ ./qemu-img.exe create -f qcow2 tinycore.img 1G
Formatting ‘tinycore.img’, fmt=qcow2, size=1048576 kB

$ qemu -cdrom /c/Users/dpinson/Downloads/tinycore_2.2.iso -hda tinycore.img -m 256 -boot d
Could not open ‘\.kqemu’ – QEMU acceleration layer not activated: 2

Next time we will build kqemu.