# 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!

- January 3, 2011: added Qemu-0.13.0-windows-Bios.zip which overrides the vga bioses for the 0.13.0 version (See the patch file vgabios-fix.diff and the corresponding debian bug report - Instructions for generating the bioses on cygwin will be provided later)
- August 22, 2011: updated for Qemu-0.14.0 and Qemu-0.15.0
- September 07, 2011: corrected the Qemu-0.14.0 and Qemu-0.15.0 zip files (thanks to Rolando A. Lopez for pointing to the packaging error: all DLLs were missing!)
- October 18, 2011: corrected the Qemu-0.14.0 and Qemu-0.15.0 zip files again (thanks to Simon Eigeldinger for pointing to the packaging error still present!) + updated for Qemu-0.15.1 + sha1sum available for my downloads (see below)
- November 1, 2011: corrected the Qemu-0.15.1 zip file (thanks to Scott LaBombard and John Taylor for reporting the compilation/link error!)
- February 13, 2012: updated for Qemu-1.0 : contains qemu-system-arm.exe, qemu-system-i386.exe, qemu-system-ppc.exe, qemu-system-sparc.exe, qemu-system-x86_64.exe and the linux-0.2.img image. libusb is now removed as it is not working correctly.
- February 29, 2012: updated for Qemu-1.0.1 - Still a "to be tested" version. See bug report win32: git rev 59f971d crashes when accessing disk (coroutine issue). In my version a workaround was to compile `coroutine-win32.c` without optimisation (`-O0`): contains qemu-system-arm.exe, qemu-system-i386.exe, qemu-system-ppc.exe, qemu-system-sparc.exe, qemu-system-x86_64.exe and the linux-0.2.img image

## Latest Windows binaries (includes FMOD support and SDL 1.2.15) :

- -Lite packages means that only the i386 virtual machine is compiled and available.
- -Medium contains also ARM, PPC and usually SPARC virtual machines.

- Qemu-1.0.1-windows.zip (18.0M) (NEW)
- Qemu-1.0-windows.zip (17.7M)
- Qemu-0.15.1-windows-Medium.zip (5.97M)

### sha1sum :

- Use the .sha1 files from the release directory...
- See here for usage of `sha1sum`.

### Old Windows binaries :

- browse the release directory...

### Links :

- QEMU : http://www.qemu.org/
- SDL : http://www.libsdl.org/
- MinGW : http://www.mingw.org/
- Cygwin: : http://www.cygwin.com/
- Qemu on windows :: Old Qemu on windows page, Tips

## How to build

NEW build done with MinGW (as it doesn't compile anymore with cygwin) The main difference is now that the build is done with MinGW by using the latest version of gcc.
You need the following packages (downloadable with the MinGW installer program) :

http://prdownloads.sourceforge.net/mingw/mingw-get-0.4-mingw32-alpha-1-bin.tar.xz?download

http://prdownloads.sourceforge.net/mingw/mingw-get-0.4-mingw32-alpha-1-lic.tar.xz?download

http://prdownloads.sourceforge.net/mingw/pkginfo-0.4-mingw32-alpha-1-bin.tar.xz?download

http://prdownloads.sourceforge.net/mingw/libiconv-1.14-2-mingw32-dll-2.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libgmp-5.0.1-1-mingw32-dll-10.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libpthreadgc-2.9.0-mingw32-pre-20110507-2-dll-2.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/pthreads-w32-2.9.0-mingw32-pre-20110507-2-dev.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libquadmath-4.6.1-2-mingw32-dll-0.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libgomp-4.6.1-2-mingw32-dll-1.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libmpc-0.8.1-1-mingw32-dll-2.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libssp-4.6.1-2-mingw32-dll-0.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libgcc-4.6.1-2-mingw32-dll-1.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libintl-0.18.1.1-2-mingw32-dll-8.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/mingwrt-3.20-mingw32-dll.tar.gz?download

http://prdownloads.sourceforge.net/mingw/w32api-3.17-2-mingw32-dev.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/mingwrt-3.20-mingw32-dev.tar.gz?download

http://prdownloads.sourceforge.net/mingw/binutils-2.21.53-1-mingw32-bin.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libexpat-2.0.1-1-mingw32-dll-1.tar.gz?download

http://prdownloads.sourceforge.net/mingw/gdb-7.3.1-1-mingw32-bin.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/make-3.82-5-mingw32-bin.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/gcc-4.6.1-2-mingw32-lic.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/libstdc++-4.6.1-2-mingw32-dll-6.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/gcc-core-4.6.1-2-mingw32-bin.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/gcc-4.6.1-2-mingw32-doc.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/gcc-4.6.1-2-mingw32-lang.tar.lzma?download

http://prdownloads.sourceforge.net/mingw/gcc-c++-4.6.1-2-mingw32-bin.tar.lzma?download

GLIB for MinGW :
Fetched GTK+ Bundle for mingw
You need the following package http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.8-20111122_win32.zip

ZLIB for MinGW :
You need the following packages
http://sourceforge.net/projects/mingw/files/MinGW/Extension/zlib/zlib-1.2.5-4/libz-1.2.5-4-mingw32-dll-1.tar.lzma/download and
http://sourceforge.net/projects/mingw/files/MinGW/Extension/zlib/zlib-1.2.5-4/libz-1.2.5-4-mingw32-dev.tar.lzma/download

Note: everything is installed for me in `D:\MinGW`.Those tar files can be extracted with the -J option of cygwin's tar if needed as the cygwin's shell is still used by me (and not the MSYS version).

SDL for MinGW :
Fetched SDL-devel-1.2.15-mingw32.tar.gz from SDL site.

DirectX:
Fetched http://sourceforge.net/projects/mingwdx/files/latest/download?source=files
and files from http://www.filehat.com/folders.php?fid=134

Qemu:

- Fetch the source code: http://wiki.qemu.org/download/qemu-1.0.1.tar.gz (or here: qemu-1.0.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-1.0.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
- Prepare the Cygwin/MinGW environement:
  Created some links in a bin directory to ease the calls to the MinGW tools:

      export PATH=/cygdrive/d/MinGW/bin:/home/lassauge/MyDocuments/Qemu/libusb-win32-device-bin-0.1.12.2/bin:$HOME/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin
      cd $HOME/bin
      ln -s /cygdrive/d/MinGW/bin/dlltool.exe i586-mingw32-dlltool
      ln -s /cygdrive/d/MinGW/bin/ld.exe i586-mingw32-ld
      ln -s /cygdrive/d/MinGW/bin/windres.exe i586-mingw32-windres

- Created a gcc wrapper to trap some of the POSIX file names to Windows file name: rename it to i586-mingw32-gcc
  Fetch the source code: gcc-wrapper.sh

      #!/bin/bash
      # ##############################################################################
      # (c) Eric Lassauge - January 2012
      # <lassauge {AT} users {DOT} sourceforge {DOT} net >
      #
      # ##############################################################################
      #    This program is free software: you can redistribute it and/or modify
      #    it under the terms of the GNU General Public License as published by
      #    the Free Software Foundation, either version 3 of the License, or
      #    (at your option) any later version.
      #
      #    This program is distributed in the hope that it will be useful,
      #    but WITHOUT ANY WARRANTY; without even the implied warranty of
      #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      #    GNU General Public License for more details.
      #
      #    You should have received a copy of the GNU General Public License
      #    along with this program.  If not, see <http://www.gnu.org/licenses/>
      # ##############################################################################
      # Complete script for MinGW gcc wrapper from cygwin: change POSIX path to windows path
      # Needs: cygpath

      #Configure to where you installed MinGW
      mingwbase=/cygdrive/d/MinGW
      mingwroot=`cygpath -w ${mingwbase}`

      dollarstar=""
      # Parse the gcc flags to change all file pathes
      while [ $# -ne 0 ]; do
      	case "$1" in
      	-o)
      		param=`cygpath -w $2`
      		dollarstar="${dollarstar} -o ${param}"
      		shift
      		;;
      	-I)
      		param=`cygpath -w $2`
      		dollarstar="${dollarstar} -I ${param}"
      		shift
      		;;
      	-I*)
      		parami=`echo $1 | sed -e 's/-I//'`
      		first=`echo ${parami} | sed -e 's/^\(.\).*/\1/'`
      		case $first in
      		'/' | '.')
      			param=`cygpath -w ${parami}`
      			dollarstar="${dollarstar} -I${param}"
      			;;
      		*)
      			dollarstar="${dollarstar} ${1}"
      			;;
      		esac
      		;;
      	-B)
      		param=`cygpath -w $2`
      		dollarstar="${dollarstar} -B ${param}"
      		shift
      		;;
      	-L)
      		param=`cygpath -w $2`
      		dollarstar="${dollarstar} -L ${param}"
      		shift
      		;;
      	-L*)
      		paraml=`echo $1 | sed -e 's/-L//'`
      		first=`echo ${paraml} | sed -e 's/^\(.\).*/\1/'`
      		case $first in
      		'/' | '.')
      			param=`cygpath -w ${paraml}`
      			dollarstar="${dollarstar} -L${param}"
      			;;
      		*)
      			dollarstar="${dollarstar} ${1}"
      			;;
      		esac
      		;;
      	*)
      		if [ -f "$1" ]
      		then
      			param=`cygpath -w $1`
      			dollarstar="${dollarstar} ${param}"
      		else
      			dollarstar="${dollarstar} $1"
      		fi
      		;;
      	esac
      	shift
      done

      # remove spurious ^M
      dollarstar=`echo "${dollarstar}" | sed -e 's/
      //g'`
      # echo "# Calling MinGW compiler: gcc ${dollarstar}"
      # Add the path to mingw tools
      export PATH=${mingwbase}/bin:$PATH
      ${mingwbase}/bin/gcc -Wl,-mi386pe --sysroot="${mingwroot}" ${dollarstar}

- Configure:

      ./configure --target-list="i386-softmmu arm-softmmu sparc-softmmu ppc-softmmu x86_64-softmmu"\
       --cc=i586-mingw32-gcc --host-cc=/usr/bin/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/Qemu/fmodapi375win/api/lib/libfmod.a \
       --fmod-inc=/home/lassauge/Qemu/fmodapi375win/api/inc \
       --enable-pie --disable-vnc-jpeg --disable-strip

- Modify the generated Makefile for calling windres from MinGW:

      125c125
      <       $(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC    $(TARGET_DIR)$@")
      ---
      >      $(call quiet-command,$(WINDRES) -I. -o $@ '$(shell cygpath -w $<)',"  RC    $(TARGET_DIR)$@")

- Make: If you want to see what is exactly compiled use `V=1 make`
- Install: do not forget to add:

      SDL.dll,
      fmod.dll,
      intl.dll,
      libgcc_s_dw2-1.dll,
      libglib-2.0-0.dll,
      libgthread-2.0-0.dll,
      libpng14-14.dll,
      libssp-0.dll,
      zlib1.dll

This program is provided as is and without any warranty.