Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 1 | Compiling and Installing |
| 2 | ======================== |
| 3 | |
Laura Ekstrand | 5aea480 | 2018-05-18 16:28:49 -0700 | [diff] [blame] | 4 | .. toctree:: |
| 5 | :maxdepth: 1 |
| 6 | :hidden: |
| 7 | |
| 8 | meson |
| 9 | |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 10 | 1. Prerequisites for building |
| 11 | ----------------------------- |
| 12 | |
| 13 | 1.1 General |
| 14 | ~~~~~~~~~~~ |
| 15 | |
| 16 | Build system |
| 17 | ^^^^^^^^^^^^ |
| 18 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 19 | - `Meson <https://mesonbuild.com>`__ is required when building on \*nix |
Matt Turner | b58fbfa | 2021-03-21 13:27:57 -0400 | [diff] [blame] | 20 | platforms and on Windows. |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 21 | - Android Build system when building as native Android component. Meson |
| 22 | is used when when building ARC. |
| 23 | |
| 24 | Compiler |
| 25 | ^^^^^^^^ |
| 26 | |
| 27 | The following compilers are known to work, if you know of others or |
| 28 | you're willing to maintain support for other compiler get in touch. |
| 29 | |
| 30 | - GCC 4.2.0 or later (some parts of Mesa may require later versions) |
Erik Faye-Lund | d30470e | 2020-09-30 15:09:37 +0200 | [diff] [blame] | 31 | - Clang - exact minimum requirement is currently unknown. |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 32 | - Microsoft Visual Studio 2015 or later is required, for building on |
| 33 | Windows. |
| 34 | |
| 35 | Third party/extra tools. |
| 36 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 37 | |
Matt Turner | b58fbfa | 2021-03-21 13:27:57 -0400 | [diff] [blame] | 38 | - `Python <https://www.python.org/>`__ - Python 3.5 or newer is required. |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 39 | - `Python Mako module <http://www.makotemplates.org/>`__ - Python Mako |
| 40 | module is required. Version 0.8.0 or later should work. |
Erik Faye-Lund | ece806d | 2021-02-03 12:11:10 +0100 | [diff] [blame] | 41 | - Lex / Yacc - for building the Mesa IR and GLSL compiler. |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 42 | |
Erik Faye-Lund | fafd1f4 | 2020-09-29 18:26:25 +0200 | [diff] [blame] | 43 | On Linux systems, Flex and Bison versions 2.5.35 and 2.4.1, |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 44 | respectively, (or later) should work. On Windows with MinGW, install |
Erik Faye-Lund | fafd1f4 | 2020-09-29 18:26:25 +0200 | [diff] [blame] | 45 | Flex and Bison with: |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 46 | |
| 47 | :: |
| 48 | |
| 49 | mingw-get install msys-flex msys-bison |
| 50 | |
| 51 | For MSVC on Windows, install `Win |
| 52 | flex-bison <http://winflexbison.sourceforge.net/>`__. |
| 53 | |
Erik Faye-Lund | bf3f0f7 | 2019-06-04 10:39:58 +0200 | [diff] [blame] | 54 | .. note:: |
| 55 | |
Erik Faye-Lund | 689145e | 2020-09-30 15:24:01 +0200 | [diff] [blame] | 56 | Some versions can be buggy (e.g. Flex 2.6.2) so do try others |
Erik Faye-Lund | bf3f0f7 | 2019-06-04 10:39:58 +0200 | [diff] [blame] | 57 | if things fail. |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 58 | |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 59 | 1.2 Requirements |
| 60 | ~~~~~~~~~~~~~~~~ |
| 61 | |
| 62 | The requirements depends on the features selected at configure stage. |
Erik Faye-Lund | 24db6ee0 | 2021-02-03 12:14:47 +0100 | [diff] [blame] | 63 | Check/install the respective development package as prompted by the |
| 64 | configure error message. |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 65 | |
| 66 | Here are some common ways to retrieve most/all of the dependencies based |
| 67 | on the packaging tool used by your distro. |
| 68 | |
| 69 | :: |
| 70 | |
| 71 | zypper source-install --build-deps-only Mesa # openSUSE/SLED/SLES |
| 72 | yum-builddep mesa # yum Fedora, OpenSuse(?) |
| 73 | dnf builddep mesa # dnf Fedora |
| 74 | apt-get build-dep mesa # Debian and derivatives |
| 75 | ... # others |
| 76 | |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 77 | 2. Building with meson |
| 78 | ---------------------- |
| 79 | |
| 80 | **Meson >= 0.46.0 is required** |
| 81 | |
| 82 | Meson is the latest build system in mesa, it is currently able to build |
| 83 | for \*nix systems like Linux and BSD, macOS, Haiku, and Windows. |
| 84 | |
| 85 | The general approach is: |
| 86 | |
| 87 | :: |
| 88 | |
| 89 | meson builddir/ |
| 90 | ninja -C builddir/ |
| 91 | sudo ninja -C builddir/ install |
| 92 | |
Erik Faye-Lund | 12d925d | 2020-09-29 18:38:30 +0200 | [diff] [blame] | 93 | On Windows you can also use the Visual Studio backend |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 94 | |
| 95 | :: |
| 96 | |
| 97 | meson builddir --backend=vs |
| 98 | cd builddir |
| 99 | msbuild mesa.sln /m |
| 100 | |
Erik Faye-Lund | 9be0e2d | 2020-06-15 12:31:36 +0200 | [diff] [blame] | 101 | Please read the :doc:`detailed meson instructions <meson>` for more |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 102 | information |
| 103 | |
Matt Turner | b58fbfa | 2021-03-21 13:27:57 -0400 | [diff] [blame] | 104 | 3. Building with AOSP (Android) |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 105 | ------------------------------- |
| 106 | |
| 107 | Currently one can build Mesa for Android as part of the AOSP project, |
| 108 | yet your experience might vary. |
| 109 | |
| 110 | In order to achieve that one should update their local manifest to point |
| 111 | to the upstream repo, set the appropriate BOARD_GPU_DRIVERS and build |
| 112 | the libGLES_mesa library. |
| 113 | |
| 114 | FINISHME: Improve on the instructions add references to Rob H |
| 115 | repos/Jenkins, Android-x86 and/or other resources. |
| 116 | |
Matt Turner | b58fbfa | 2021-03-21 13:27:57 -0400 | [diff] [blame] | 117 | 4. Library Information |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 118 | ---------------------- |
| 119 | |
| 120 | When compilation has finished, look in the top-level ``lib/`` (or |
| 121 | ``lib64/``) directory. You'll see a set of library files similar to |
| 122 | this: |
| 123 | |
| 124 | :: |
| 125 | |
| 126 | lrwxrwxrwx 1 brian users 10 Mar 26 07:53 libGL.so -> libGL.so.1* |
| 127 | lrwxrwxrwx 1 brian users 19 Mar 26 07:53 libGL.so.1 -> libGL.so.1.5.060100* |
| 128 | -rwxr-xr-x 1 brian users 3375861 Mar 26 07:53 libGL.so.1.5.060100* |
| 129 | lrwxrwxrwx 1 brian users 14 Mar 26 07:53 libOSMesa.so -> libOSMesa.so.6* |
| 130 | lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSMesa.so.6.1.060100* |
| 131 | -rwxr-xr-x 1 brian users 23871 Mar 26 07:53 libOSMesa.so.6.1.060100* |
| 132 | |
| 133 | **libGL** is the main OpenGL library (i.e. Mesa), while **libOSMesa** is |
| 134 | the OSMesa (Off-Screen) interface library. |
| 135 | |
| 136 | If you built the DRI hardware drivers, you'll also see the DRI drivers: |
| 137 | |
| 138 | :: |
| 139 | |
| 140 | -rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i915_dri.so |
| 141 | -rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i965_dri.so |
| 142 | -rwxr-xr-x 1 brian users 11849858 Jul 21 12:12 r200_dri.so |
| 143 | -rwxr-xr-x 1 brian users 11757388 Jul 21 12:12 radeon_dri.so |
| 144 | |
| 145 | If you built with Gallium support, look in lib/gallium/ for |
| 146 | Gallium-based versions of libGL and device drivers. |
| 147 | |
Matt Turner | b58fbfa | 2021-03-21 13:27:57 -0400 | [diff] [blame] | 148 | 5. Building OpenGL programs with pkg-config |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 149 | ------------------------------------------- |
| 150 | |
| 151 | Running ``ninja install`` will install package configuration files for |
| 152 | the pkg-config utility. |
| 153 | |
| 154 | When compiling your OpenGL application you can use pkg-config to |
| 155 | determine the proper compiler and linker flags. |
| 156 | |
| 157 | For example, compiling and linking a GLUT application can be done with: |
| 158 | |
| 159 | :: |
| 160 | |
| 161 | gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo |