Search code examples
qemu

Compile QEMU under Windows 10 (64-bit) for Windows 10 (64-bit)


I managed to compile QEMU (3.0.50) under Windows 10 (64-bit) (basically following these instructions) with these commands:

./configure --enable-gtk --enable-sdl
make

However, when starting qemu-system-x86_64.exe in a console, nothing happens. I expected a window showing up. Shortly after starting the exe, I'm getting back the prompt. Nothing printed out to the console. No necessary DLL is missing. What could be the problem?


Solution

  • Finally I managed to compile and run QEMU under Windows 10 Home 64-bit. There are a few pitfalls:

    1. Due to a compiler bug in mingw (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86832 and https://www.mail-archive.com/[email protected]/msg557409.html), you have to configure QEMU with --disable-stack-protector and (one solution) add the function __stack_chk_fail to a source file.
    2. Configure QEMU with --disable-werror.
    3. Remove Capstone project from makefile.

    Here's a complete step-by-step guide for compiling qemu-system-x86_64.exe:

    Date: 2018-10-31

    OS: Microsoft Windows 10 Home 64-bit

    Guide based on: https://wiki.qemu.org/Hosts/W32#Native_builds_with_MSYS2

    • Download and install msys2 to C:\msys64: http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20180531.exe
    • Start C:\msys64\mingw64.exe
    • Updates (then close window and restart mingw64.exe): pacman -Syu
    • Updates: pacman -Su
    • Install basic packets: pacman -S base-devel mingw-w64-x86_64-toolchain git python
    • Install QEMU specific packets: pacman -S mingw-w64-x86_64-glib2 mingw-w64-x86_64-gtk3 mingw-w64-x86_64-SDL2
    • Get QEMU sources:
      • git clone git://git.qemu-project.org/qemu.git
      • cd qemu
      • git submodule update --init ui/keycodemapdb
      • git submodule update --init capstone
      • git submodule update --init dtc
    • Insert void __stack_chk_fail(void); void __stack_chk_fail(void) { } to qemu\util\oslib-win32.c e.g. at line 44
    • Comment out (#) Capstone (line 508) in qemu\Makefile
    • Build QEMU:
      • ./configure --enable-gtk --enable-sdl --target-list=x86_64-softmmu --disable-werror --disable-stack-protector
      • make
    • Run in qemu/x86_64-softmmu ./qemu-system-x86_64 -L ./../pc-bios
    • Optional (for better performance): Install HAXM according to this guide: https://www.qemu.org/2017/11/22/haxm-usage-windows/ and start QEMU with option -accel hax