To build QEMU for Windows 10 or higher with hardware-accelerated virtualization via WHPX, install the Windows SDK (I recommend using Chocolatey) and follow these instructions within a MinGW shell:

  1. Install the dependencies (taken from the Windows CI script):

    Bashpacman -Sy --noconfirm --needed \
          diffutils git grep make sed \
          mingw-w64-x86_64-capstone \
          mingw-w64-x86_64-curl \
          mingw-w64-x86_64-cyrus-sasl \
          mingw-w64-x86_64-gcc \
          mingw-w64-x86_64-glib2 \
          mingw-w64-x86_64-gnutls \
          mingw-w64-x86_64-libnfs \
          mingw-w64-x86_64-libpng \
          mingw-w64-x86_64-libssh \
          mingw-w64-x86_64-libtasn1 \
          mingw-w64-x86_64-libusb \
          mingw-w64-x86_64-nettle \
          mingw-w64-x86_64-ninja \
          mingw-w64-x86_64-pixman \
          mingw-w64-x86_64-pkgconf \
          mingw-w64-x86_64-python \
          mingw-w64-x86_64-SDL2 \
          mingw-w64-x86_64-SDL2_image \
          mingw-w64-x86_64-snappy \
          mingw-w64-x86_64-usbredir \
  2. Copy the desired version of the WHPX headers (adapted from RceNinja’s notes on GitHub—the Windows Kits directory was under the root for me):

    Bashcp /c/Windows\ Kits/10/Include/10.0.19041.0/um/WinHv* /mingw64/x86_64-w64-mingw32/include/
  3. Clone the QEMU source:

    Bashgit clone && cd qemu
  4. Initialize the submodules with git submodule init && git submodule update -r. This might be done automatically by the configure script, but I did it in advance per the notes linked above.

  5. Create the output directory and run export OUTPUT_PATH=path/to/output/directory.

  6. Create a subdirectory for the build inside the source directory.

  7. Run the configure script from within the build subdirectory:

    Bash../configure --prefix=$OUTPUT_PATH \
                 --target-list=x86_64-softmmu,i386-softmmu --enable-whpx \
                 --enable-tools --enable-lzo --enable-bzip2 --enable-sdl \
                 --enable-gtk --enable-vdi --enable-hax --disable-capstone
  8. Run make -j (or -j N to use only N CPUs). It takes a while and the output can appear to pause mid-word.

  9. Run make install.

The binaries produced can be run from the output directory (QEMU-bin/qemu-system-x86_64w.exe --accel whpx) in Windows without any further action. Note that there is no debug information attached. See RceNinja’s notes for what to copy if you need it.