build-environment.rst 3.3 KB

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