0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows 用 QEmu の自前ビルド

Last updated at Posted at 2024-08-09

1. MSYS2 のインストール

 MSYS2 の Installation セクションから msys2-x86_64-********.exe をダウンロードし、インストーラーにしたがって C:\msys64 にインストールします。

2. qemu-system-x86_64.exe のビルド

 これから⇩の環境で qemu: 9.0.50.0 のビルドを行います。

$ pacman -Q msys2-runtime
msys2-runtime 3.5.3-4

 インストールディレクトリが C:\msys64 の場合は "C:\msys64\mingw64.exe" をダブルクリックし実行します。
※※ コマンドの貼り付けは [ Shift + Insert ] または [ Insert ] キーを押下します。複数行の場合には [ Shift + Insert ] のほうが良いと思います。※※

MINGW64
# 3回くらい実行しておく・ Y は4回くらい入力することになります
pacman -Syu
pacman -Syu
pacman -Syu

# パッケージのインストール
pacman -S --needed base-devel \
          git \
          python \
          python-setuptools \
          ninja

# 依存関係のインストール
pacman -S --needed mingw-w64-x86_64-glib2 \
          mingw-w64-x86_64-pixman \
          mingw-w64-x86_64-gtk3 \
          mingw-w64-x86_64-SDL2 \
          mingw-w64-x86_64-libslirp \
          mingw-w64-x86_64-toolchain \
          mingw-w64-x86_64-python-sphinx \
          mingw-w64-x86_64-python-sphinx_rtd_theme \
          mingw-w64-x86_64-meson

# ソースコードのダウンロード・依存関係の解決
git clone https://gitlab.com/qemu-project/qemu.git
cd qemu
git submodule init
git submodule update --recursive


#################################################
## 以下は上記の dependencies だけでは足りなかった ##
## 場合に実行                                   ##
#################################################

pacman -Sy mingw-w64-x86_64-meson \
           mingw-w64-x86_64-ninja \
           mingw-w64-x86_64-python \
           mingw-w64-x86_64-python-sphinx \
           mingw-w64-x86_64-python-sphinx_rtd_theme \
           mingw-w64-x86_64-autotools \
           mingw-w64-x86_64-tools-git \
           mingw-w64-x86_64-cc \
           mingw-w64-x86_64-angleproject \
           mingw-w64-x86_64-capstone \
           mingw-w64-x86_64-curl \
           mingw-w64-x86_64-cyrus-sasl \
           mingw-w64-x86_64-expat \
           mingw-w64-x86_64-fontconfig \
           mingw-w64-x86_64-freetype \
           mingw-w64-x86_64-fribidi \
           mingw-w64-x86_64-gcc-libs \
           mingw-w64-x86_64-gdk-pixbuf2 \
           mingw-w64-x86_64-gettext \
           mingw-w64-x86_64-glib2 \
           mingw-w64-x86_64-gmp \
           mingw-w64-x86_64-gnutls \
           mingw-w64-x86_64-graphite2 \
           mingw-w64-x86_64-gst-plugins-base \
           mingw-w64-x86_64-gstreamer \
           mingw-w64-x86_64-gtk3 \
           mingw-w64-x86_64-harfbuzz \
           mingw-w64-x86_64-jbigkit \
           mingw-w64-x86_64-lerc \
           mingw-w64-x86_64-libc++ \
           mingw-w64-x86_64-libdatrie \
           mingw-w64-x86_64-libdeflate \
           mingw-w64-x86_64-libepoxy \
           mingw-w64-x86_64-libffi \
           mingw-w64-x86_64-libiconv \
           mingw-w64-x86_64-libidn2 \
           mingw-w64-x86_64-libjpeg-turbo \
           mingw-w64-x86_64-libnfs \
           mingw-w64-x86_64-libpng \
           mingw-w64-x86_64-libpsl \
           mingw-w64-x86_64-libslirp \
           mingw-w64-x86_64-libssh \
           mingw-w64-x86_64-libssh2 \
           mingw-w64-x86_64-libtasn1 \
           mingw-w64-x86_64-libthai \
           mingw-w64-x86_64-libtiff \
           mingw-w64-x86_64-libunistring \
           mingw-w64-x86_64-libunwind \
           mingw-w64-x86_64-libusb \
           mingw-w64-x86_64-libwebp \
           mingw-w64-x86_64-libwinpthread-git \
           mingw-w64-x86_64-lz4 \
           mingw-w64-x86_64-lzo2 \
           mingw-w64-x86_64-nettle \
           mingw-w64-x86_64-openssl \
           mingw-w64-x86_64-opus \
           mingw-w64-x86_64-orc \
           mingw-w64-x86_64-p11-kit \
           mingw-w64-x86_64-pango \
           mingw-w64-x86_64-pixman \
           mingw-w64-x86_64-SDL2 \
           mingw-w64-x86_64-SDL2_image \
           mingw-w64-x86_64-snappy \
           mingw-w64-x86_64-spice \
           mingw-w64-x86_64-usbredir \
           mingw-w64-x86_64-xz \
           mingw-w64-x86_64-zlib \
           mingw-w64-x86_64-zstd

 管理者権限で "C:\msys64\mingw64.exe" を再度実行します。
 また以下は MSYS2 のインストールディレクトリが C:\msys64 の場合です。

MINGW64:管理者
# シンボリックリンクを使って別名を用意
test -d "C:/msys64/mingw64/bin" && echo True
cd C:/msys64/mingw64/bin
ln ar.exe x86_64-w64-mingw32-ar.exe
ln ranlib.exe x86_64-w64-mingw32-ranlib.exe
ln windres.exe x86_64-w64-mingw32-windres.exe
ln nm.exe x86_64-w64-mingw32-nm.exe
ln objcopy.exe x86_64-w64-mingw32-objcopy.exe

# configure を使ってソースコードを Windows 環境に合わせて設定
cd ~/qemu
./configure --enable-gtk \
            --enable-sdl \
            --target-list=x86_64-softmmu \
            --disable-werror \
            --disable-capstone \
            --prefix=/artifacts

exit

 管理者権限で "C:\msys64\mingw64.exe" を再再実行します。

MINGW64:管理者
# コンパイル
cd ~/qemu/build
meson compile
ls -l ~/qemu/build/qemu-bundle/msys64/artifacts

# インストール
# meson install

 ここでは meson install の代わりに手動で構成します。
※※meson install を実行した場合は ./configure --prefix=/artifacts で指定した場所(ここでは /artifacts )にて構成されています。ただし、*.dllqemu-system-x86_64.exe があるディレクトリと同じ階層に自分でコピーしてくる必要があります。※※
 管理者権限でコマンドプロンプトを起動します。

CMD:管理者
chcp 65001

:: 各々の環境に合わせて調整してください
set "SRC=C:\msys64\home\%USERNAME%\qemu\build\qemu-bundle\msys64\artifacts"
set "DEST=\\任意のディレクトリ"
set "DLL=C:\msys64\mingw64\bin"

:: チェック
if defined SRC @if exist "%SRC%" echo True
if defined DEST @for %i in ("%DEST%") do @if exist "%~dpi" echo True
if defined DLL @if exist "%DLL%" echo True

:: 保存先の予約
robocopy "%SRC%" "%DEST%" /B /J /A-:SH /MIR /DCOPY:DATE /COPYALL /E /CREATE /XX /XO /XN /R:0 /W:0 /V

:: シンボリックリンクを解決してコピー
robocopy "%SRC%" "%DEST%" /B /J /A-:SH /MIR /DCOPY:DATE /COPYALL /E /IM /IT /XX /R:0 /W:0 /V

:: 依存関係をコピー
xcopy "%DLL%\*.dll" "%DEST%" /i /c /f /k /r /x
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?