Hosts - W32 - QEMU
Hosts - W32 - QEMU
org/Hosts/W32
Hosts/W32
QEMU on W32 and W64 hosts
This documentation is work in progress - more information will be added as needed.
While QEMU's main host platform is Linux, it is sometimes also useful to build or run it on
members of the W32 / W64 family of operating systems (MS Windows 8, Windows 10,
Windows 11, ...) or on ReactOS (a W32 clone). Support for W64 was added in QEMU 1.1. See
https://www.qemu.org/docs/master/about/build-platforms.html#windows for information
about which versions of Windows are currently supported.
Please note that less developers work on QEMU for W32 / W64 hosts, so it might be less stable.
Also note that the building process of QEMU involves some Python scripts that call os.symlink()
which needs special attention for the build process to successfully complete. On newer versions
of Windows 10, unprivileged accounts can create symlinks if Developer Mode is enabled. When
Developer Mode is not available/enabled, the SeCreateSymbolicLinkPrivilege privilege is
required, or the process must be run as an administrator.
Cross builds
Compilation of QEMU for W32 on non-W32 hosts (e.g. Linux hosts) is called cross compilation.
Some Linux distributions (Debian, Ubuntu, Fedora and maybe others) already include packages
needed for cross compilation, so the installation of these packages is the first step.
Note: Building on Debian squeeze is no longer supported, so the following commands won't
work with latest QEMU.
SDL support is not included in standard MinGW, but packages for MinGW are available on the
SDL homepage. POSIX thread support is not included in Debian or Ubuntu. Latest QEMU will
1 di 7 23/04/2024, 13:27
Hosts/W32 - QEMU https://wiki.qemu.org/Hosts/W32
need it, so you have to get it from MinGW (see links below).
Cross compilers usually are installed in /usr/bin with a prefix. For Debian, the cross gcc is
called i586-mingw32msvc-gcc. This cross prefix must be passed to QEMU's configure.
Compiler option is needed for gcc versions which don't support TLS (thread local storage)
without it (version 4.4 which is Debian's default needs it!).
Debian does not include a cross pkg-config, but it is required for cross builds. The following
script can be saved as /usr/bin/i586-mingw32msvc-pkg-config and optionally be linked to
/usr/bin/amd64-mingw32msvc-pkg-config.
#!/bin/sh
basename=`basename $0`
prefix=/usr/`echo $basename|sed s/-pkg-config//`
PKG_CONFIG_LIBDIR=$prefix/lib/pkgconfig
export PKG_CONFIG_LIBDIR
pkg-config --define-variable=prefix=$prefix $@
These instructions were tested with the Linux Mint Debian Edition on 2012-06-02.
Add http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_11.4
(update with your release version) to the list of software repositories. Then install at least the
following packets (most of them are pulled via dependencies):
mingw32-binutils
mingw32-cpp
mingw32-cross-binutils
mingw32-cross-cpp
mingw32-cross-gcc
mingw32-cross-pkg-config
mingw32-filesystem
mingw32-gcc
mingw32-glib2
mingw32-glib2-devel
mingw32-glib2-lang
mingw32-headers
mingw32-libgcc
2 di 7 23/04/2024, 13:27
Hosts/W32 - QEMU https://wiki.qemu.org/Hosts/W32
mingw32-libgmp
mingw32-libintl
mingw32-libintl-devel
mingw32-libmpc
mingw32-libmpfr
mingw32-libSDL
mingw32-libSDL-devel
mingw32-libssp
mingw32-runtime
mingw32-zlib
mingw32-zlib-devel
This toolchain does not include libiberty.a in its binutils package, but it also does not need to. If
building against a QEMU version that still pulls this in unconditionally, simply drop the
-liberty from configure.
For W64 use the corresponding win64 repository and mingw64- packages.
Cross compilers usually are installed in /usr/bin with a prefix. This cross prefix must be passed
to QEMU's configure. The prefix depends on your target platform.
Note that "-mingw32-w64" appears in prefix for both W32 and W64 builds.
As of June 2016, the master tree supports "docker based compiling", which can be used for
convenient windows cross build.
Make sure your docker command works ("docker ps" or "sudo docker ps" reports no error), then
cd into the root of QEMU source tree and run
, it will download and initialize the needed docker image for you, and drop you into a shell in the
3 di 7 23/04/2024, 13:27
Hosts/W32 - QEMU https://wiki.qemu.org/Hosts/W32
cd $QEMU_SRC
then
./configure --cross-prefix=x86_64-w64-mingw32-
or
./configure --cross-prefix=i686-w64-mingw32-
Get and install Mingw-w64. In addition, some more packages are needed:
▪ pkg-config (http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-
config_0.23-3_win32.zip)
Get the QEMU source code (git or tarball), then run configure and make.
Builds with the normal Cygwin compiler are not supported. Nevertheless, cygwin can be used as
a build environment because it also contains all necessary Mingw-w64 packages.
4 di 7 23/04/2024, 13:27
Hosts/W32 - QEMU https://wiki.qemu.org/Hosts/W32
Required packages
▪ mingw64-i686-gcc-g++
▪ mingw64-i686-glib2.0
▪ mingw64-i686-pixman
▪ mingw64-i686-pkg-config
Recommended packages
▪ mingw64-i686-curl
▪ mingw64-i686-gtk3
▪ mingw64-i686-libssh2
▪ mingw64-i686-libtasn1
▪ mingw64-i686-nettle
▪ mingw64-i686-ncurses
▪ mingw64-i686-gnutls
Optional packages
▪ mingw64-i686-SDL2
▪ mingw64-i686-libgcrypt
▪ mingw64-i686-libusb1.0
▪ mingw64-i686-usbredir
Cross builds
Compilation of QEMU for W64 on non-W64 hosts (e.g. Linux hosts) is called cross compilation.
Some Linux distributions (Debian, Ubuntu, Fedora and maybe others) already include packages
needed for cross compilation, so the installation of these packages is the first step.
5 di 7 23/04/2024, 13:27
Hosts/W32 - QEMU https://wiki.qemu.org/Hosts/W32
▪ As per the MSYS2 documentation, download the latest repository updates with:
pacman -Syu
▪ If required, restart the MSYS2 console. Then update the remaining packages with:
pacman -Su
▪ Then install any required QEMU-specific packages. For a basic setup you can use:
▪ Additional optional features require more packages. For example, to enable GTK+ and SDL
user interface and user networking you can use:
cd qemu
./configure --enable-sdl --enable-gtk
make
Installation
6 di 7 23/04/2024, 13:27
Hosts/W32 - QEMU https://wiki.qemu.org/Hosts/W32
System emulation
All QEMU system emulation should be working (that simply means I don't know of emulations
which don't work, and those which I tried, namely x86 and mips, work well).
Hardware acceleration for x86 can be enabled with the command line option --enable-whpx.
QEMU is based on Mingw-w64, so some commonly used UNIX device names like /dev/null or
/dev/zero can be used. W32 device names also work, especially names like //./PhysicalDrive0
for the first hard disk of the host (this name must be used with extreme care or you will likely
crash your system).
Text which is normally printed by QEMU to the console output channels (normally known as
standard output = stdout and standard error output = stderr) might be written to files called
stdout.txt and stderr.txt if QEMU was linked with SDL 1.2. If you want to see QEMU's help
messages or if it does not work as expected, you should look for these files in the directory
where your exe file is installed.
Links
Mingw-w64 Website (supports both 32 and 64 bit builds)
http://mingw-w64.sourceforge.net/
7 di 7 23/04/2024, 13:27