compiling_for_x11.rst 9.7 KB

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