compiling_for_x11.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. .. _doc_compiling_for_x11:
  2. Compiling for X11 (Linux, \*BSD)
  3. ================================
  4. .. highlight:: shell
  5. Requirements
  6. ------------
  7. For compiling under Linux or other Unix variants, the following is
  8. required:
  9. - GCC or Clang
  10. - Python 3 or 2.7+
  11. - SCons build system (3.0 or later for Python 3)
  12. - pkg-config (used to detect the dependencies below)
  13. - X11, Xcursor, Xinerama, Xi and XRandR development libraries
  14. - MesaGL development libraries
  15. - ALSA development libraries
  16. - PulseAudio development libraries
  17. - *Optional* - libudev (build with ``udev=yes``)
  18. - *Optional* - yasm (for WebM SIMD optimizations)
  19. .. seealso:: For a general overview of SCons usage for Godot, see
  20. :ref:`doc_introduction_to_the_buildsystem`.
  21. Distro-specific oneliners
  22. ^^^^^^^^^^^^^^^^^^^^^^^^^
  23. +------------------+-----------------------------------------------------------------------------------------------------------+
  24. | **Alpine Linux** | :: |
  25. | | |
  26. | | apk add scons pkgconf gcc g++ libx11-dev libxcursor-dev libxinerama-dev libxi-dev libxrandr-dev \ |
  27. | | libexecinfo-dev |
  28. +------------------+-----------------------------------------------------------------------------------------------------------+
  29. | **Arch Linux** | :: |
  30. | | |
  31. | | pacman -S scons pkgconf gcc libxcursor libxinerama libxi libxrandr mesa glu alsa-lib pulseaudio yasm |
  32. +------------------+-----------------------------------------------------------------------------------------------------------+
  33. | **Debian** / | :: |
  34. | **Ubuntu** | |
  35. | | sudo apt-get install build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev \ |
  36. | | libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev yasm |
  37. +------------------+-----------------------------------------------------------------------------------------------------------+
  38. | **Fedora** | :: |
  39. | | |
  40. | | sudo dnf install scons pkgconfig libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel \ |
  41. | | libXi-devel mesa-libGL-devel mesa-libGLU-devel alsa-lib-devel pulseaudio-libs-devel \ |
  42. | | libudev-devel yasm |
  43. +------------------+-----------------------------------------------------------------------------------------------------------+
  44. | **FreeBSD** | :: |
  45. | | |
  46. | | sudo pkg install scons pkgconf xorg-libraries libXcursor libXrandr libXi xorgproto libGLU alsa-lib \ |
  47. | | pulseaudio yasm |
  48. | | |
  49. +------------------+-----------------------------------------------------------------------------------------------------------+
  50. | **Gentoo** | :: |
  51. | | |
  52. | | emerge -an dev-util/scons x11-libs/libX11 x11-libs/libXcursor x11-libs/libXinerama x11-libs/libXi \ |
  53. | | media-libs/mesa media-libs/glu media-libs/alsa-lib media-sound/pulseaudio dev-lang/yasm |
  54. +------------------+-----------------------------------------------------------------------------------------------------------+
  55. | **Mageia** | :: |
  56. | | |
  57. | | urpmi scons task-c++-devel pkgconfig "pkgconfig(alsa)" "pkgconfig(glu)" "pkgconfig(libpulse)" \ |
  58. | | "pkgconfig(udev)" "pkgconfig(x11)" "pkgconfig(xcursor)" "pkgconfig(xinerama)" "pkgconfig(xi)" \ |
  59. | | "pkgconfig(xrandr)" yasm |
  60. +------------------+-----------------------------------------------------------------------------------------------------------+
  61. | **OpenBSD** | :: |
  62. | | |
  63. | | pkg_add python scons llvm yasm |
  64. +------------------+-----------------------------------------------------------------------------------------------------------+
  65. | **openSUSE** | :: |
  66. | | |
  67. | | sudo zypper install scons pkgconfig libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel \ |
  68. | | libXi-devel Mesa-libGL-devel alsa-devel libpulse-devel libudev-devel libGLU1 yasm |
  69. +------------------+-----------------------------------------------------------------------------------------------------------+
  70. | **Solus** | :: |
  71. | | |
  72. | | sudo eopkg install -c system.devel scons libxcursor-devel libxinerama-devel libxi-devel \ |
  73. | | libxrandr-devel mesalib-devel libglu alsa-lib-devel pulseaudio-devel yasm |
  74. +------------------+-----------------------------------------------------------------------------------------------------------+
  75. Compiling
  76. ---------
  77. Start a terminal, go to the root dir of the engine source code and type:
  78. ::
  79. user@host:~/godot$ scons -j8 platform=x11
  80. A good rule of thumb for the ``-j`` (*jobs*) flag, is to have at least as many
  81. threads compiling Godot as you have cores in your CPU, if not one or two more.
  82. Feel free to add the ``-j`` option to any SCons command you see below.
  83. If all goes well, the resulting binary executable will be placed in the
  84. "bin" subdirectory. This executable file contains the whole engine and
  85. runs without any dependencies. Executing it will bring up the project
  86. manager.
  87. .. note::
  88. If you wish to compile using Clang rather than GCC, use this command:
  89. ::
  90. user@host:~/godot$ scons platform=x11 use_llvm=yes
  91. Using Clang appears to be a requirement for OpenBSD, otherwise fonts
  92. would not build.
  93. .. note:: If you are compiling Godot for production use, then you can
  94. make the final executable smaller and faster by adding the
  95. SCons option ``target=release_debug``.
  96. Building export templates
  97. -------------------------
  98. .. warning:: Linux binaries usually won't run on distributions that are
  99. older than the distribution they were built on. If you wish to
  100. distribute binaries that work on most distributions,
  101. you should build them on an old distribution such as Ubuntu 16.04.
  102. You can use a virtual machine or a container to set up a suitable
  103. build environment.
  104. To build X11 (Linux, \*BSD) export templates, run the build system with the
  105. following parameters:
  106. - (32 bits)
  107. ::
  108. user@host:~/godot$ scons platform=x11 tools=no target=release bits=32
  109. user@host:~/godot$ scons platform=x11 tools=no target=release_debug bits=32
  110. - (64 bits)
  111. ::
  112. user@host:~/godot$ scons platform=x11 tools=no target=release bits=64
  113. user@host:~/godot$ scons platform=x11 tools=no target=release_debug bits=64
  114. Note that cross-compiling for the opposite bits (64/32) as your host
  115. platform is not always straight-forward and might need a chroot environment.
  116. To create standard export templates, the resulting files must be copied to:
  117. ::
  118. $HOME/.local/share/godot/templates/[gd-version]/
  119. and named like this (even for \*BSD which is seen as "Linux X11" by Godot):
  120. ::
  121. linux_x11_32_debug
  122. linux_x11_32_release
  123. linux_x11_64_debug
  124. linux_x11_64_release
  125. However, if you are writing your custom modules or custom C++ code, you
  126. might instead want to configure your binaries as custom export templates
  127. here:
  128. .. image:: img/lintemplates.png
  129. You don't even need to copy them, you can just reference the resulting
  130. files in the ``bin/`` directory of your Godot source folder, so the next
  131. time you build, you automatically have the custom templates referenced.