Help us understand the problem. What is going on with this article?

QEMUをMinGWでコンパイルする。

QEMUをMinGWでコンパイルする。

エミュレータをコードリーディングするにあたり
Windows上で動作するソースコードをコンパイルする。

利用環境

Mingw (MSYS2 64bit)
Qemu-2.6.0 on Windows

QEMU ON WINDOWS
で配布されているソースコードと、configureのパッチを用いる。

MSYS2のセットアップ

image.png
image.png

基本的な開発ツールのインストール

pacman -S base-devel mingw-w64-x86_64-toolchain git

image.png

pacman -S mingw-w64-x86_64-gtk3

image.png

pacman -S mingw-w64-x86_64-toolchain
pacman -S perl

QEMUのconfigureパッチ

QEMU ON WINDOWS
で配布されているソースコードと、configureのパッチを用いる。

patch --verbose -b configure  qemu-2.6.0.patch

その他、編集

config-host.makの編集

以下のとおり、それぞれ編集する。

AR=x86_64-w64-mingw32-ar

AR=x86_64-w64-mingw32-gcc-ar

WINDRES=x86_64-w64-mingw32-windres

WINDRES=windres

NM=x86_64-w64-mingw32-nm

NM=x86_64-w64-mingw32-gcc-nm

OBJCOPY=x86_64-w64-mingw32-objcopy

OBJCOPY=objcopy

AS=x86_64-w64-mingw32-as

AS=as

LD=x86_64-w64-mingw32-ld

LD=ld

# Automatically generated by configure - do not modify

all:
prefix=/home/lassauge/MyDocuments/Qemu-windows
bindir=${prefix}
libdir=${prefix}/lib
libexecdir=${prefix}/libexec
includedir=${prefix}/include
mandir=${prefix}
sysconfdir=${prefix}
qemu_confdir=${prefix}/Bios
qemu_datadir=${prefix}/Bios
qemu_docdir=/home/lassauge/MyDocuments/Qemu-windows/Doc
qemu_moddir=${prefix}/lib/Bios
qemu_helperdir=${prefix}/libexec
extra_cflags=-m64 
extra_ldflags=
qemu_localedir=${prefix}/locale
libs_softmmu=-LD:/ITInst/msys64/mingw64/lib -lpixman-1 -lole32 -ldxguid -LD:/ITInst/msys64/mingw64/lib -lpng16 -lz -ljpeg -LD:/ITInst/msys64/mingw64/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lz -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lfribidi -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -mwindows -llzo2 -L$(BUILD_DIR)/dtc/libfdt -lfdt
ARCH=x86_64
CONFIG_WIN32=y
CONFIG_FILEVERSION=2,6,0,0
CONFIG_PRODUCTVERSION=2,6,0,0
CONFIG_QGA_NTDDDISK=y
CONFIG_SLIRP=y
CONFIG_SMBD_COMMAND="/usr/sbin/smbd"
CONFIG_AUDIO_DRIVERS=dsound
CONFIG_DSOUND=y
CONFIG_AUDIO_WIN_INT=y
CONFIG_BDRV_RW_WHITELIST=
CONFIG_BDRV_RO_WHITELIST=
CONFIG_VNC=y
CONFIG_VNC_JPEG=y
CONFIG_VNC_PNG=y
VERSION=2.6.0
PKGVERSION=
SRC_PATH=/home/m-mas/qemu-2.6.0
TARGET_DIRS=i386-softmmu arm-softmmu sparc-softmmu ppc-softmmu x86_64-softmmu mipsel-softmmu
BUILD_DOCS=yes
CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y
GLIB_CFLAGS=-pthread -mms-bitfields -ID:/ITInst/msys64/mingw64/include/glib-2.0 -ID:/ITInst/msys64/mingw64/lib/glib-2.0/include -ID:/ITInst/msys64/mingw64/include
CONFIG_GTK=y
CONFIG_GTKABI=3.0
GTK_CFLAGS=-mms-bitfields -pthread -mms-bitfields -ID:/ITInst/msys64/mingw64/include/gtk-3.0 -ID:/ITInst/msys64/mingw64/include/cairo -ID:/ITInst/msys64/mingw64/include -ID:/ITInst/msys64/mingw64/include/pango-1.0 -ID:/ITInst/msys64/mingw64/include/fribidi -ID:/ITInst/msys64/mingw64/include/atk-1.0 -ID:/ITInst/msys64/mingw64/include/cairo -ID:/ITInst/msys64/mingw64/include/pixman-1 -ID:/ITInst/msys64/mingw64/include -ID:/ITInst/msys64/mingw64/include/freetype2 -ID:/ITInst/msys64/mingw64/include -ID:/ITInst/msys64/mingw64/include/harfbuzz -ID:/ITInst/msys64/mingw64/include/libpng16 -ID:/ITInst/msys64/mingw64/include/gdk-pixbuf-2.0 -ID:/ITInst/msys64/mingw64/include/libpng16 -ID:/ITInst/msys64/mingw64/include -ID:/ITInst/msys64/mingw64/include/glib-2.0 -ID:/ITInst/msys64/mingw64/lib/glib-2.0/include -ID:/ITInst/msys64/mingw64/include -DINPUT_NEEDS_ALTGR_FIX
GTK_LIBS=-LD:/ITInst/msys64/mingw64/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lz -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lfribidi -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
CONFIG_TASN1=y
INSTALL_BLOBS=yes
CONFIG_FDT=y
CONFIG_LZO=y
CONFIG_BZIP2=y
BZIP2_LIBS=-lbz2
CONFIG_ZERO_MALLOC=y
CONFIG_LOCALTIME_R=y
CONFIG_QOM_CAST_DEBUG=y
CONFIG_COROUTINE_BACKEND=win32
CONFIG_COROUTINE_POOL=1
CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y
CONFIG_CPUID_H=y
CONFIG_INT128=y
HOST_USB=stub
CONFIG_TPM=$(CONFIG_SOFTMMU)
TRACE_BACKENDS=log
CONFIG_TRACE_LOG=y
CONFIG_TRACE_FILE=trace
CONFIG_THREAD_SETNAME_BYTHREAD=y
CONFIG_PTHREAD_SETNAME_NP=y
TOOLS=qemu-ga qemu-img$(EXESUF) qemu-io$(EXESUF) 
ROMS=optionrom
MAKE=make
INSTALL=install
INSTALL_DIR=install -d -m 0755
INSTALL_DATA=install -c -m 0644
INSTALL_PROG=install -c -m 0755
INSTALL_LIB=install -c -m 0644
PYTHON=/usr/bin/python2.7 -B
CC=x86_64-w64-mingw32-gcc
CC_I386=$(CC) -m32
HOST_CC=/usr/bin/gcc
CXX=x86_64-w64-mingw32-g++
OBJCC=x86_64-w64-mingw32-gcc
AR=x86_64-w64-mingw32-gcc-ar
ARFLAGS=rv
AS=as
CPP=x86_64-w64-mingw32-gcc -E
OBJCOPY=objcopy
LD=ld
NM=x86_64-w64-mingw32-gcc-nm
WINDRES=windres
CFLAGS=-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -pthread -mms-bitfields -ID:/ITInst/msys64/mingw64/include/glib-2.0 -ID:/ITInst/msys64/mingw64/lib/glib-2.0/include -ID:/ITInst/msys64/mingw64/include -g 
CFLAGS_NOPIE=
QEMU_CFLAGS=-ID:/ITInst/msys64/mingw64/include/pixman-1 -I$(SRC_PATH)/dtc/libfdt -m64 -mthreads -D__USE_MINGW_ANSI_STDIO=1 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common  -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong  -ID:/ITInst/msys64/mingw64/include/libpng16 -ID:/ITInst/msys64/mingw64/include
QEMU_INCLUDES=-I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/i386 -I. -I$(SRC_PATH) -I$(SRC_PATH)/include
AUTOCONF_HOST := --host=x86_64-w64-mingw32
LDFLAGS=-m64 -g 
LDFLAGS_NOPIE=
LIBS+=-LD:/ITInst/msys64/mingw64/lib -lgthread-2.0 -pthread -lglib-2.0 -lintl -lwinmm -lws2_32 -liphlpapi  -lz
LIBS_TOOLS+=
EXESUF=.exe
DSOSUF=.dll
LDFLAGS_SHARED=-shared
LIBS_QGA+=-lsetupapi -LD:/ITInst/msys64/mingw64/lib -lgthread-2.0 -pthread -lglib-2.0 -lintl -lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 
TASN1_LIBS=-LD:/ITInst/msys64/mingw64/lib -ltasn1
TASN1_CFLAGS=-ID:/ITInst/msys64/mingw64/include
POD2MAN=pod2man --utf8
TRANSLATE_OPT_CFLAGS=
config-host.h: subdir-dtc

ビルド

./configure --target-list="i386-softmmu arm-softmmu sparc-softmmu ppc-softmmu x86_64-softmmu mipsel-softmmu" \
 --cc=x86_64-w64-mingw32-gcc --cxx=x86_64-w64-mingw32-g++ --host-cc=/usr/bin/gcc --audio-drv-list="dsound"\
 --cross-prefix=x86_64-w64-mingw32- \
 --prefix=/home/lassauge/MyDocuments/Qemu-windows \
 --with-confsuffix=/Bios \
 --docdir=/home/lassauge/MyDocuments/Qemu-windows/Doc \
 --disable-sdl \
 --enable-gtk --with-gtkabi=3.0 \
 --disable-libusb \
 --enable-guest-agent \
 --disable-werror \
 --python=/usr/bin/python2.7 \
 --disable-strip $*

make

実行

ホスト(Windows10側)に環境変数Pathを設定すること。

以上

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした