blob: 2878f8a84f9b23022cbf9e0e73d98391d947046a [file] [log] [blame]
Erik Faye-Lund4d066832020-06-12 20:09:42 +02001Compiling and Installing
2========================
3
Laura Ekstrand5aea4802018-05-18 16:28:49 -07004.. toctree::
5 :maxdepth: 1
6 :hidden:
7
8 meson
9
Erik Faye-Lund4d066832020-06-12 20:09:42 +0200101. Prerequisites for building
11-----------------------------
12
131.1 General
14~~~~~~~~~~~
15
16Build system
17^^^^^^^^^^^^
18
Erik Faye-Lunde198fb62020-09-29 18:20:24 +020019- `Meson <https://mesonbuild.com>`__ is required when building on \*nix
Matt Turnerb58fbfa2021-03-21 13:27:57 -040020 platforms and on Windows.
Erik Faye-Lund4d066832020-06-12 20:09:42 +020021- Android Build system when building as native Android component. Meson
22 is used when when building ARC.
23
24Compiler
25^^^^^^^^
26
27The following compilers are known to work, if you know of others or
28you'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-Lundd30470e2020-09-30 15:09:37 +020031- Clang - exact minimum requirement is currently unknown.
Erik Faye-Lund4d066832020-06-12 20:09:42 +020032- Microsoft Visual Studio 2015 or later is required, for building on
33 Windows.
34
35Third party/extra tools.
36^^^^^^^^^^^^^^^^^^^^^^^^
37
Matt Turnerb58fbfa2021-03-21 13:27:57 -040038- `Python <https://www.python.org/>`__ - Python 3.5 or newer is required.
Erik Faye-Lund4d066832020-06-12 20:09:42 +020039- `Python Mako module <http://www.makotemplates.org/>`__ - Python Mako
40 module is required. Version 0.8.0 or later should work.
Erik Faye-Lundece806d2021-02-03 12:11:10 +010041- Lex / Yacc - for building the Mesa IR and GLSL compiler.
Erik Faye-Lund4d066832020-06-12 20:09:42 +020042
Erik Faye-Lundfafd1f42020-09-29 18:26:25 +020043 On Linux systems, Flex and Bison versions 2.5.35 and 2.4.1,
Erik Faye-Lund4d066832020-06-12 20:09:42 +020044 respectively, (or later) should work. On Windows with MinGW, install
Erik Faye-Lundfafd1f42020-09-29 18:26:25 +020045 Flex and Bison with:
Erik Faye-Lund4d066832020-06-12 20:09:42 +020046
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-Lundbf3f0f72019-06-04 10:39:58 +020054.. note::
55
Erik Faye-Lund689145e2020-09-30 15:24:01 +020056 Some versions can be buggy (e.g. Flex 2.6.2) so do try others
Erik Faye-Lundbf3f0f72019-06-04 10:39:58 +020057 if things fail.
Erik Faye-Lund4d066832020-06-12 20:09:42 +020058
Erik Faye-Lund4d066832020-06-12 20:09:42 +0200591.2 Requirements
60~~~~~~~~~~~~~~~~
61
62The requirements depends on the features selected at configure stage.
Erik Faye-Lund24db6ee02021-02-03 12:14:47 +010063Check/install the respective development package as prompted by the
64configure error message.
Erik Faye-Lund4d066832020-06-12 20:09:42 +020065
66Here are some common ways to retrieve most/all of the dependencies based
67on 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-Lund4d066832020-06-12 20:09:42 +0200772. Building with meson
78----------------------
79
80**Meson >= 0.46.0 is required**
81
82Meson is the latest build system in mesa, it is currently able to build
83for \*nix systems like Linux and BSD, macOS, Haiku, and Windows.
84
85The general approach is:
86
87::
88
89 meson builddir/
90 ninja -C builddir/
91 sudo ninja -C builddir/ install
92
Erik Faye-Lund12d925d2020-09-29 18:38:30 +020093On Windows you can also use the Visual Studio backend
Erik Faye-Lund4d066832020-06-12 20:09:42 +020094
95::
96
97 meson builddir --backend=vs
98 cd builddir
99 msbuild mesa.sln /m
100
Erik Faye-Lund9be0e2d2020-06-15 12:31:36 +0200101Please read the :doc:`detailed meson instructions <meson>` for more
Erik Faye-Lund4d066832020-06-12 20:09:42 +0200102information
103
Matt Turnerb58fbfa2021-03-21 13:27:57 -04001043. Building with AOSP (Android)
Erik Faye-Lund4d066832020-06-12 20:09:42 +0200105-------------------------------
106
107Currently one can build Mesa for Android as part of the AOSP project,
108yet your experience might vary.
109
110In order to achieve that one should update their local manifest to point
111to the upstream repo, set the appropriate BOARD_GPU_DRIVERS and build
112the libGLES_mesa library.
113
114FINISHME: Improve on the instructions add references to Rob H
115repos/Jenkins, Android-x86 and/or other resources.
116
Matt Turnerb58fbfa2021-03-21 13:27:57 -04001174. Library Information
Erik Faye-Lund4d066832020-06-12 20:09:42 +0200118----------------------
119
120When compilation has finished, look in the top-level ``lib/`` (or
121``lib64/``) directory. You'll see a set of library files similar to
122this:
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
134the OSMesa (Off-Screen) interface library.
135
136If 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
145If you built with Gallium support, look in lib/gallium/ for
146Gallium-based versions of libGL and device drivers.
147
Matt Turnerb58fbfa2021-03-21 13:27:57 -04001485. Building OpenGL programs with pkg-config
Erik Faye-Lund4d066832020-06-12 20:09:42 +0200149-------------------------------------------
150
151Running ``ninja install`` will install package configuration files for
152the pkg-config utility.
153
154When compiling your OpenGL application you can use pkg-config to
155determine the proper compiler and linker flags.
156
157For 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