I still can’t see how to build this for win64 … 🙁
The first major stumbling block on Win32 is glib, and again going back to the MinGW wiki there is a good laundry list of how to bootstrap Glib on MinGW.
Things you’ll need:
Be sure to run ming-get install for the following:
- gcc
- g++
- libiconv
- zlib
- libz
- gettext
- msys
- msys-perl
- msys-m4
Install Python.. Nothing to fancy from what I gather Qemu still requires you have a level 2 Python, not 3 …
Build libffi
This should be the usual dance of configure & make / make install… Â But sure to at least run configure like this:
./configure –prefix=/mingw
Build Glib without pkg-config
Be sure to add Python to your path..
PATH=/c/Python27:/c/Python27/DLLs:$PATH
export PATH
Glib is packed with something called ‘xz’ so hopefully you have xzcat .. Otherwise add it!
export LIBFFI_CFLAGS=’-I /mingw/lib/libffi-3.0.9/include’
export LIBFFI_LIBS=-lffi
export lt_cv_deplibs_check_method=”pass_all”
export CFLAGS=â€-O0 -g -pipe -Wall -march=i486 -mms-bitfields -mthreadsâ€
export CPPFLAGS=â€-DG_ATOMIC_OP_USE_GCC_BUILTINS=1â€
export LDFLAGS=â€-Wl,–enable-auto-image-baseâ€
configure –prefix=/mingw –with-pcre=internal –disable-static –disable-gtk-doc –enable-silent-rules
*Â You may have some weird issue where when running configure it tells you it cannot create executables, or you get a bunch of weird errors trying to paste in the CFLAGS line.. For me the MinGW prompt was stripping the quotes and the leading – to the -O0 (disable optimization) bit. Â I don’t know what on earth its issue was, but I had to type that line in manually.
Then do the make/make install dance. This will take a WHILE. At least with -pipe it’ll run each stage of GCC on multiple processors… But yeah.. This is intense to build. Â Good thing we get to do it twice.
I also ran into some weird error in the GIO directory where it couldn’t find my Python, and was looking for python2.5 .. So I copied python.exe to python2.5.exe …
PYTHON = /usr/bin/env python2.5
pkg-config
Naturally pkg-config depends on Glib2, and pkg-config to build… Which of course is a circular problem, much like Glib2 requires pkg-config to build. Â So to configure it, it goes something like this now that we’ve built a Glib2 ..
export GLIB_CFLAGS=”-I/mingw/include/glib-2.0 -I/mingw/lib/glib-2.0/include”
export GLIB_LIBS=”-lglib-2.0″
configure –prefix=/mingw
At the same time I can’t help but wonder if this version of pkg-config can use it’s own Glib with the following config:
configure –prefix=/mingw –with-internal-glib
Anyways with any luck we can now build & install pkg-config. Â This only takes a few seconds..
Glib2 (again)
From this point you should open a new MinGW prompt window, as you don’t want the old CFLAGS screwing things up. Â Re-eport the Python path/dll vars and now we can get on to building glib2 (again!) …
configure –prefix=/mingw;make;make install
SDL
This should be somewhat straightforward …
configure –prefix=/mingw;make;make install
In the old days we built zlib, but now we can just quickly add in the package (as we did way above) so we should.. now be ready for the main event!
And now we can finally build Qemu 1.1.1-1!!!
Now there is a few things I like to tweak, the first is in the configure script, I like to add in AdLib support. Â Look for the line
audio_card_list=”ac97 es1370 sb16 hda”
and add adlib into the list
audio_card_list=”ac97 es1370 sb16 hda adlib”
Next I like to modify hw/pc.c and alter the ISA NE2000, as Qemu doesn’t like to share IRQ 9 with the card, so it is just easier to remove the 0x300/IRQ 9 definition.
static const int ne2000_io[NE2000_NB_MAX] = { 0x300, 0x320, 0x340, 0x360,
0x280, 0x380 };
static const int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 };
to this:
static const int ne2000_io[NE2000_NB_MAX] = { 0x320, 0x340, 0x360,
0x280, 0x380 };
static const int ne2000_irq[NE2000_NB_MAX] = { 10, 11, 3, 4, 5 };
The next tweak deals with the ability to use older qcow2 disk images… I guess converting them to RAW with an older version of Qemu, then using the new version of Qemu to convert them back into qcow2’s may be a “good ideaâ„¢” but for now modifying the source is a quicker fix.
Comment out the “return -EINVAL;” in block/qcow2.c
if (ext.len > end_offset – offset) {
error_report(“Header extension too large”);
//return -EINVAL;
}
Now one fun thing I’ve noticed is that building with the default O2 flags Qemu will crash out the moment you access a hard disk image.  It appears that coroutine-win32 is at issue (again?).  So the “easy” way I address it is to first build qemu as normal, and verify that if you attach a hard disk image (any kind) and try to access it, partition it etc, it should crash.  Next remove the file coroutine-win32.o , and edit the file config-host.mak and change the CFLAGS that specify
CFLAGS=-O2 -g
to
CFLAGS=-O1 -g
Now run make again, and it *should* just rebuild coroutine-win32.o with the lesser optimization flags, and relink all the exe’s.  If I’ve done this right, you should now have a working Qemu.
You can go ahead and strip the binaries if you so please, but that should be it.
PHEW. Â For anyone who wants my build, but doesn’t want to go through this ‘exciting’ process, you can find the Win32 i386 build here.
In preliminary testing I’ve found this version to be MUCH slower than 0.15.1 .. I think it has something to do with it wanting to scale the SDL window.  Also I’ve had issues with various network cards not initializing with the BIOS that ships with this version of Qemu so I’ve included the bios directory from 0.15.1 .  And lastly yes the disk images… I’ve had major issues with my qcow2 disks, and disk corruption with this build.  I’ve gone ahead and  included the qemu-img tool from 0.15.1 so you can convert qcow2 to raw, then use the 1.1.1 tool to take them from raw back into qcow2 … But I’d probably only do it as a test.
You may want to kick the tires on this version but 0.15.1 really blows this one away…