QEMU on Windows

-----------------

QEMU is an emulator for various CPUs. It works on Linux, Windows, FreeBSD and Mac OS X. Windows version is in an alpha stage. I hope I can provide useful information on development and usage of the software.

What's New!

Latest Windows binaries (includes preliminary USB support, FMOD support and SDL 1.2.14):

sha1sum :

Old Windows binaries :

Links

QEMU:
http://www.qemu.org/
SDL library:
http://www.libsdl.org/
Cygwin:
http://www.cygwin.com/

How to build

WARNING: build process is still using the "old" 1.5.25 cygwin legacy version (see here for informations).

Main choice was to build everything from cygwin by using the mingw versions of gcc.
You need the following packages (downloadable with the cygwin setup-legacy program):

gcc-mingw-core gcc-mingw-core-20050522-1.tar.bz2

gcc-mingw-g++ gcc-mingw-g++-20050522-1.tar.bz2

mingw-runtime mingw-runtime-3.16-1.tar.bz2

mingw-zlib-devel mingw-zlib-devel-1.2.3-3.tar.bz2

mingw-libbz2-devel mingw-libbz2-devel-1.0.5-3.tar.bz2

w32api w32api-3.13-1.tar.bz2

SDL : based on http://www.libsdl.org/extras/win32/cygwin/README.txt

-          Fetch the source code (SDL-1.2.14.tar.gz was used) and untar.

-          Fetch the DirectX development headers and libraries (new version rebuild with gcc –mno-cygwin and –O4 –march=i686 available here: mingw-directx-5.0-EL.tar.bz2) : http://www.libsdl.org/extras/win32/cygwin/directx-devel.tar.gz

-          Fetch yasm (http://www.tortall.net/projects/yasm/releases/yasm-0.8.0-cygwin.exe or here: yasm.exe), put it in your path.

-          Fetch libunicows.a: http://libunicows.sourceforge.net/ (installable version build with make -f makefile.mingw32 CC="gcc –mno-cygwin" and CFLAGS="–O4 –march=i686" available here: mingw-libunicows-1.1.2-EL.tar.bz2)

-          Compile SDL and install:

CPPFLAGS="-I/usr/include/mingw " CFLAGS="-O4 -march=i686 -fomit-frame-pointer -funroll-loops -I/include/w32api" CC="gcc -mno-cygwin" CXXFLAGS="-O4 -march=i686 -fomit-frame-pointer -funroll-loops -I/include/w32api" CXX="g++ -mno-cygwin" ./configure LDFLAGS="-mno-cygwin" --prefix=/usr --libdir=/usr/lib/mingw --includedir=/usr/include/mingw
make
make install

-          A complete package (reworked with mingw compatibility in mind) is available here: mingw-SDL-1.2.14-EL-2.tar.bz2)

Qemu:

-          Fetch the source code: http://wiki.qemu.org/download/qemu-0.15.1.tar.gz

-          Optionally fetch the fmod library: http://www.fmod.org/index.php/release/version/fmodapi375win.zip (or here: fmodapi375win.zip)

-          Fetch and install the patches: qemu-0.15.1-patch. This patch is based on the original patches found here: http://www.h7.dion.ne.jp/~qemu-win/download/qemu-0.9.0-patches.zip plus my additional work (+ corrected for unmodified Ubuntu with the help of Dmitry Zhurikhin).

-          Fetch LibUsb-Win32, currently http://downloads.sourceforge.net/libusb-win32/libusb-win32-device-bin-0.1.12.2.tar.gz, or here: libusb-win32-device-bin-0.1.12.2.tar.gz and untar.

-          Untar Qemu, apply the patch (patch -p1 -i ../qemu-0.15.1-patch) and configure:

PATH=/home/lassauge/MyDocuments/Qemu/libusb-win32-device-bin-0.1.12.2/bin:$PATH CFLAGS="-O4 -march=i686" \
./configure --target-list="i386-softmmu arm-softmmu sparc-softmmu ppc-softmmu" \
--cc="gcc -mno-cygwin" --host-cc=gcc --audio-drv-list="dsound sdl fmod" --audio-card-list="ac97 es1370 sb16 cs4231a adlib gus" \
--prefix="/home/lassauge/MyDocuments/Qemu-windows" \
--fmod-lib=/home/lassauge/MyDocuments/Qemu/fmodapi375win/api/lib/libfmod.a \
--fmod-inc=/home/lassauge/MyDocuments/Qemu/fmodapi375win/api/inc

-          Special tweak (starting from version 0.9.1): I modify the config-host.mak file for CFLAGS. You should have something like this (check HOST_USB and CONFIG_FMOD) + removed libliberty, libpng and libglib-2.0 as they are not used/installed on mingw based cygwin compilation:

all:
prefix=/home/lassauge/MyDocuments/Qemu-windows
bindir=${prefix}
libdir=${prefix}/lib
mandir=${prefix}
datadir=${prefix}
sysconfdir=${prefix}
docdir=${prefix}
confdir=${prefix}
ARCH=i386
STRIP=strip
HOST_LONG_BITS=32
CONFIG_WIN32=y
CONFIG_FILEVERSION=0,15,1,0
CONFIG_PRODUCTVERSION=0,15,1,0
CONFIG_SLIRP=y
CONFIG_SMBD_COMMAND="/usr/sbin/smbd"
CONFIG_AC97=y
CONFIG_ES1370=y
CONFIG_SB16=y
CONFIG_CS4231A=y
CONFIG_ADLIB=y
CONFIG_GUS=y
CONFIG_AUDIO_DRIVERS=dsound sdl fmod
CONFIG_DSOUND=y
CONFIG_SDL=y
CONFIG_FMOD=y
FMOD_CFLAGS=-I/home/lassauge/MyDocuments/Qemu/fmodapi375win/api/inc
CONFIG_AUDIO_WIN_INT=y
CONFIG_BDRV_WHITELIST=
CONFIG_VNC=y
#CONFIG_VNC_PNG=
#VNC_PNG_CFLAGS=
VERSION=0.15.1
PKGVERSION=
SRC_PATH=/home/lassauge/Qemu/qemu-0.15.1
TARGET_DIRS=i386-softmmu arm-softmmu sparc-softmmu ppc-softmmu
BUILD_DOCS=yes
CONFIG_SDL=y
SDL_CFLAGS=-mno-cygwin -Dmain=SDL_main -I/usr/include/mingw/SDL -I/usr/include/mingw  
GLIB_CFLAGS=
INSTALL_BLOBS=yes
CONFIG_SMARTCARD=y
CONFIG_UNAME_RELEASE=""
CONFIG_ZERO_MALLOC=y
HOST_USB=libusb
LIBUSB_LIBS=-L/home/lassauge/MyDocuments/Qemu/libusb-win32-device-bin-0.1.12.2/lib/gcc -lusb
TRACE_BACKEND=nop
CONFIG_TRACE_FILE=trace
TOOLS=qemu-img$(EXESUF) qemu-io$(EXESUF) 
ROMS=optionrom
MAKE=make
INSTALL=install
INSTALL_DIR=install -d -m 0755
INSTALL_DATA=install -c -m 0644
INSTALL_PROG=install -c -m 0755
PYTHON=python
CC=gcc -mno-cygwin
CC_I386=$(CC) -m32
HOST_CC=gcc
AR=ar
OBJCOPY=objcopy
LD=ld
WINDRES=windres
LIBTOOL=libtool
CFLAGS=-O4 -march=i686
QEMU_CFLAGS=-march=i686 -D__USE_MINGW_ANSI_STDIO=1 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing  -Wendif-labels -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wold-style-definition -I/usr/include/libpng12  
QEMU_INCLUDES=-I$(SRC_PATH)/slirp -I. -I$(SRC_PATH) -I/home/lassauge/MyDocuments/Qemu/libusb-win32-device-bin-0.1.12.2/include
HELPER_CFLAGS=-fomit-frame-pointer
LDFLAGS=-Wl,--warn-common -march=i686
ARLIBS_BEGIN=
ARLIBS_END=
LIBS+=-lwinmm -lws2_32 -liphlpapi $(LIBUSB_LIBS)
LIBS_TOOLS+=-lintl -liconv  
EXESUF=.exe
subdir-i386-softmmu: subdir-libhw64
subdir-arm-softmmu: subdir-libhw32
subdir-sparc-softmmu: subdir-libhw64
subdir-ppc-softmmu: subdir-libhw32

-          One important erroneous compilation warning: printf formats for int64 objects from mingw include files are not recognized by the compiler (bug?) but it works as expected. You can verify with the following file compiled on cygwin with and without -mno-cygwin:

#include <stdio.h>
#include <basetsd.h>/* required typedef __int64 for gcc */

typedef char TCHAR;

#define TEXT(x) x
unsigned __int64 atou64(const TCHAR *s) ;
int main()
{
	unsigned __int64 value;
	TCHAR *test = "1234567890123456789";
	printf("in main(): test = <%s>\n", test);
	printf("sizeof(__int64) = %d\n", sizeof(__int64));
	value = atou64(test);
	printf("value using I64d: %I64d\n", value); /* for Borland BCC or Microsoft VC++ */
	printf("value using Ld:   %Ld\n", value); /* for Borland BCC */
	printf("value using lld:  %lld\n", value); /* for gcc */
	printf("value using I64x: %016I64x(hex)\n", value);/* for Borland BCC or Microsoft VC++ */
	printf("value using Lx:   %016Lx(hex)\n", value);/* for Borland BCC */
	printf("value using llx:  %016llx(hex)\n", value); /* for gcc */
	return 0;
}
unsigned __int64 atou64(const TCHAR *s) 
{ 
	const unsigned __int64 max64 = (unsigned __int64)0-1; 
	unsigned __int64 v = 0; 
	int digit; 
	while (*s>=TEXT('0') && *s<=TEXT('9')) 
	{ 
		digit = *s++ - TEXT('0'); 
		if (v > (max64-digit)/10) 
			return 0; /* overflow */ 
		v = 10*v + digit; 
	} 
	return v; 
}

-          Make: If you want to see what is exactly compiled use V=1 make

-          Install: do not forget to add fmod.dll, SDL.dll, mgwz.dll and libusb0.dll

-          Bugs:
Pathnames in the options when starting Qemu must use a single slash '/' instead of '\'.

-----------------

This program is provided as is and without any warranty.