|
| 1 | + |
| 2 | +.. _setup-build-env: |
| 3 | + |
| 4 | +Setup build environment |
| 5 | +======================= |
| 6 | + |
| 7 | +QEMU uses a lot of dependencies on the host system. glib2 is used everywhere in |
| 8 | +the code base, and most of the other dependencies are optional. |
| 9 | + |
| 10 | +We present here simple instructions to enable native builds on most popular |
| 11 | +systems. |
| 12 | + |
| 13 | +You can find additional instructions on `QEMU wiki <https://wiki.qemu.org/>`_: |
| 14 | + |
| 15 | +- `Linux <https://wiki.qemu.org/Hosts/Linux>`_ |
| 16 | +- `MacOS <https://wiki.qemu.org/Hosts/Mac>`_ |
| 17 | +- `Windows <https://wiki.qemu.org/Hosts/W32>`_ |
| 18 | +- `BSD <https://wiki.qemu.org/Hosts/BSD>`_ |
| 19 | + |
| 20 | +Note: Installing dependencies using your package manager build dependencies may |
| 21 | +miss out on deps that have been newly introduced in qemu.git. In more, it misses |
| 22 | +deps the distribution has decided to exclude. |
| 23 | + |
| 24 | +Linux |
| 25 | +----- |
| 26 | + |
| 27 | +Fedora |
| 28 | +++++++ |
| 29 | + |
| 30 | +:: |
| 31 | + |
| 32 | + sudo dnf update && sudo dnf builddep qemu |
| 33 | + |
| 34 | +Debian/Ubuntu |
| 35 | ++++++++++++++ |
| 36 | + |
| 37 | +You first need to enable `Sources List <https://wiki.debian.org/SourcesList>`_. |
| 38 | +Then, use apt to install dependencies: |
| 39 | + |
| 40 | +:: |
| 41 | + |
| 42 | + sudo apt update && sudo apt build-dep qemu |
| 43 | + |
| 44 | +MacOS |
| 45 | +----- |
| 46 | + |
| 47 | +You first need to install `Homebrew <https://brew.sh/>`_. Then, use it to |
| 48 | +install dependencies: |
| 49 | + |
| 50 | +:: |
| 51 | + |
| 52 | + brew update && brew install $(brew deps --include-build qemu) |
| 53 | + |
| 54 | +Windows |
| 55 | +------- |
| 56 | + |
| 57 | +You first need to install `MSYS2 <https://www.msys2.org/>`_. |
| 58 | +MSYS2 offers `different environments <https://www.msys2.org/docs/environments/>`_. |
| 59 | +x86_64 environments are based on GCC, while aarch64 is based on Clang. |
| 60 | + |
| 61 | +We recommend to use MINGW64 for windows-x86_64 and CLANGARM64 for windows-aarch64 |
| 62 | +(only available on windows-aarch64 hosts). |
| 63 | + |
| 64 | +Then, you can open a windows shell, and enter msys2 env using: |
| 65 | + |
| 66 | +:: |
| 67 | + |
| 68 | + c:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64 |
| 69 | + # Replace -ucrt64 by -clangarm64 or -ucrt64 for other environments. |
| 70 | + |
| 71 | +MSYS2 package manager does not offer a built-in way to install build |
| 72 | +dependencies. You can start with this list of packages using pacman: |
| 73 | + |
| 74 | +Note: Dependencies need to be installed again if you use a different MSYS2 |
| 75 | +environment. |
| 76 | + |
| 77 | +:: |
| 78 | + |
| 79 | + # update MSYS2 itself, you need to reopen your shell at the end. |
| 80 | + pacman -Syu |
| 81 | + pacman -S \ |
| 82 | + base-devel binutils bison diffutils flex git grep make sed \ |
| 83 | + ${MINGW_PACKAGE_PREFIX}-toolchain \ |
| 84 | + ${MINGW_PACKAGE_PREFIX}-glib2 \ |
| 85 | + ${MINGW_PACKAGE_PREFIX}-gtk3 \ |
| 86 | + ${MINGW_PACKAGE_PREFIX}-libnfs \ |
| 87 | + ${MINGW_PACKAGE_PREFIX}-libssh \ |
| 88 | + ${MINGW_PACKAGE_PREFIX}-ninja \ |
| 89 | + ${MINGW_PACKAGE_PREFIX}-pixman \ |
| 90 | + ${MINGW_PACKAGE_PREFIX}-pkgconf \ |
| 91 | + ${MINGW_PACKAGE_PREFIX}-python \ |
| 92 | + ${MINGW_PACKAGE_PREFIX}-SDL2 \ |
| 93 | + ${MINGW_PACKAGE_PREFIX}-zstd |
| 94 | + |
| 95 | +If you want to install all dependencies, it's possible to use recipe used to |
| 96 | +build QEMU in MSYS2 itself. |
| 97 | + |
| 98 | +:: |
| 99 | + |
| 100 | + pacman -S wget |
| 101 | + wget https://raw.githubusercontent.com/msys2/MINGW-packages/refs/heads/master/mingw-w64-qemu/PKGBUILD |
| 102 | + # Some packages may be missing for your environment, installation will still |
| 103 | + # be done though. |
| 104 | + makepkg -s PKGBUILD || true |
| 105 | + |
| 106 | +Build on windows-aarch64 |
| 107 | +++++++++++++++++++++++++ |
| 108 | + |
| 109 | +When trying to cross compile meson for x86_64 using UCRT64 or MINGW64 env, |
| 110 | +configure will run into an error because the cpu detected is not correct. |
| 111 | + |
| 112 | +Meson detects x86_64 processes emulated, so you need to manually set the cpu, |
| 113 | +and force a cross compilation (with empty prefix). |
| 114 | + |
| 115 | +:: |
| 116 | + |
| 117 | + ./configure --cpu=x86_64 --cross-prefix= |
| 118 | + |
0 commit comments