4

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?

3
  • Anything in the event log?
    – rustyx
    Oct 31 '18 at 13:50
  • Ah. Thanks. Good idea. Yes. There's an event: Faulting application name: qemu-system-x86_64.exe, Version: 3.0.50.0, time stamp: 0x00000000 Faulting module name: qemu-system-x86_64.exe, Version: 3.0.50.0, time stamp: 0x00000000 Exception code: 0xc0000005 Fault offset: 0x00000000003da784
    – Jo123
    Oct 31 '18 at 14:13
  • How do I find best the reason for the crash? Rebuild QEMU with ./configure --enable-debug added and then debugging it?
    – Jo123
    Oct 31 '18 at 14:20
8

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/qemu-devel@nongnu.org/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
1
  • 4
    Instead of commenting out capstone line, you can add --disable-capstone to configure arguments. Commenting out did not work for me. Dec 11 '18 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.