1 | Compiling and Installing
|
---|
2 | ========================
|
---|
3 |
|
---|
4 | .. toctree::
|
---|
5 | :maxdepth: 1
|
---|
6 | :hidden:
|
---|
7 |
|
---|
8 | meson
|
---|
9 |
|
---|
10 | 1. Prerequisites for building
|
---|
11 | -----------------------------
|
---|
12 |
|
---|
13 | 1.1 General
|
---|
14 | ~~~~~~~~~~~
|
---|
15 |
|
---|
16 | Build system
|
---|
17 | ^^^^^^^^^^^^
|
---|
18 |
|
---|
19 | - `Meson <https://mesonbuild.com>`__ is required when building on \*nix
|
---|
20 | platforms and on Windows.
|
---|
21 | - Android Build system when building as native Android component. Meson
|
---|
22 | is used 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 8.0.0 or later (some parts of Mesa may require later versions)
|
---|
31 | - Clang 5.0 or later (some parts of Mesa may require later versions)
|
---|
32 | - Microsoft Visual Studio 2019 Version 16.11 or later and
|
---|
33 | Windows SDK of at least 20348 is required, for building on Windows.
|
---|
34 |
|
---|
35 | Third party/extra tools.
|
---|
36 | ^^^^^^^^^^^^^^^^^^^^^^^^
|
---|
37 |
|
---|
38 | - `Python <https://www.python.org/>`__ - Python 3.6 or newer is required.
|
---|
39 | - Python package ``packaging`` is required on Python 3.12+:
|
---|
40 | ``pip install packaging``
|
---|
41 | - `Python Mako module <https://www.makotemplates.org/>`__ - Python Mako
|
---|
42 | module is required. Version 0.8.0 or later should work.
|
---|
43 | - Lex / Yacc - for building the Mesa IR and GLSL compiler.
|
---|
44 |
|
---|
45 | On Linux systems, Flex and Bison versions 2.5.35 and 2.4.1,
|
---|
46 | respectively, (or later) should work. On Windows with MinGW, install
|
---|
47 | Flex and Bison with:
|
---|
48 |
|
---|
49 | .. code-block:: console
|
---|
50 |
|
---|
51 | mingw-get install msys-flex msys-bison
|
---|
52 |
|
---|
53 | For MSVC on Windows, install `Win
|
---|
54 | flex-bison <https://sourceforge.net/projects/winflexbison/>`__.
|
---|
55 |
|
---|
56 | .. note::
|
---|
57 |
|
---|
58 | Some versions can be buggy (e.g. Flex 2.6.2) so do try others
|
---|
59 | if things fail.
|
---|
60 |
|
---|
61 | 1.2 Requirements
|
---|
62 | ~~~~~~~~~~~~~~~~
|
---|
63 |
|
---|
64 | The requirements depends on the features selected at configure stage.
|
---|
65 | Check/install the respective development package as prompted by the
|
---|
66 | configure error message.
|
---|
67 |
|
---|
68 | Here are some common ways to retrieve most/all of the dependencies based
|
---|
69 | on the packaging tool used by your distro.
|
---|
70 |
|
---|
71 | .. code-block:: console
|
---|
72 |
|
---|
73 | zypper source-install --build-deps-only Mesa # openSUSE/SLED/SLES
|
---|
74 | yum-builddep mesa # yum Fedora, OpenSuse(?)
|
---|
75 | dnf builddep mesa # dnf Fedora
|
---|
76 | apt-get build-dep mesa # Debian and derivatives
|
---|
77 | ... # others
|
---|
78 |
|
---|
79 | 1. Building with meson
|
---|
80 | ----------------------
|
---|
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 | .. code-block:: console
|
---|
88 |
|
---|
89 | meson setup builddir/
|
---|
90 | meson compile -C builddir/
|
---|
91 | sudo meson install -C builddir/
|
---|
92 |
|
---|
93 | On Windows you can also use the Visual Studio backend
|
---|
94 |
|
---|
95 | .. code-block:: console
|
---|
96 |
|
---|
97 | meson setup builddir --backend=vs
|
---|
98 | cd builddir
|
---|
99 | msbuild mesa.sln /m
|
---|
100 |
|
---|
101 | Please read the :doc:`detailed meson instructions <meson>` for more
|
---|
102 | information
|
---|
103 |
|
---|
104 | 1. Running against a local build (easy way)
|
---|
105 | -------------------------------------------
|
---|
106 |
|
---|
107 | It's often necessary or useful when debugging driver issues or testing new
|
---|
108 | branches to run against a local build of Mesa without doing a system-wide
|
---|
109 | install. Meson has built-in support for this with its ``devenv`` subcommand:
|
---|
110 |
|
---|
111 | .. code-block:: console
|
---|
112 |
|
---|
113 | meson devenv -C builddir glxinfo
|
---|
114 |
|
---|
115 | This will run the given command against the build in ``builddir``. Note that meson
|
---|
116 | will ``chdir`` into the directory first, so any relative paths in the command line
|
---|
117 | will be relative to ``builddir`` which may not be what you expect.
|
---|
118 |
|
---|
119 | 1. Running against a local build (hard way)
|
---|
120 | -------------------------------------------
|
---|
121 |
|
---|
122 | If you prefer you can configure your test environment manually. To do this,
|
---|
123 | choose a temporary location for the install. A directory called ``installdir``
|
---|
124 | inside your mesa tree is as good as anything. All of the commands below will
|
---|
125 | assume ``$MESA_INSTALLDIR`` is an absolute path to this location.
|
---|
126 |
|
---|
127 | First, configure Mesa and install in the temporary location:
|
---|
128 |
|
---|
129 | .. code-block:: console
|
---|
130 |
|
---|
131 | meson setup builddir/ -Dprefix="$MESA_INSTALLDIR" OTHER_OPTIONS
|
---|
132 | meson install -C builddir/
|
---|
133 |
|
---|
134 | where ``OTHER_OPTIONS`` is replaced by any meson configuration options you may
|
---|
135 | want. For instance, if you want to build the LLVMpipe drivers, it would look
|
---|
136 | like this:
|
---|
137 |
|
---|
138 | .. code-block:: console
|
---|
139 |
|
---|
140 | meson setup builddir/ -Dprefix="$MESA_INSTALLDIR" \
|
---|
141 | -Dgallium-drivers=swrast -Dvulkan-drivers=swrast
|
---|
142 | meson install -C builddir/
|
---|
143 |
|
---|
144 | Once Mesa has built and installed to ``$MESA_INSTALLDIR``, you can run any app
|
---|
145 | against your temporary install by setting the right environment variables.
|
---|
146 | Which variable you have to set depends on the API.
|
---|
147 |
|
---|
148 | OpenGL
|
---|
149 | ~~~~~~
|
---|
150 |
|
---|
151 | .. code-block:: console
|
---|
152 |
|
---|
153 | LD_LIBRARY_PATH="$MESA_INSTALLDIR/lib64" glxinfo
|
---|
154 |
|
---|
155 | You may need to use ``lib`` instead of ``lib64`` on some systems or a full
|
---|
156 | library specifier on debian. Look inside ``installdir`` for the directory that
|
---|
157 | contains ``libGL.so`` and use that one.
|
---|
158 |
|
---|
159 | Vulkan
|
---|
160 | ~~~~~~
|
---|
161 |
|
---|
162 | .. code-block:: console
|
---|
163 |
|
---|
164 | VK_ICD_FILENAMES="$MESA_INSTALLDIR/share/vulkan/icd/my_icd.json" vulkaninfo
|
---|
165 |
|
---|
166 | where ``my_icd.json`` is replaced with the actual ICD json file name. This
|
---|
167 | will depend on your driver. For instance, the 64-bit Lavapipe driver ICD file
|
---|
168 | is named ``lvp_icd.x86_64.json``.
|
---|
169 |
|
---|
170 | OpenCL
|
---|
171 | ~~~~~~
|
---|
172 |
|
---|
173 | .. code-block:: console
|
---|
174 |
|
---|
175 | OCL_ICD_VENDORS="$MESA_INSTALLDIR/etc/OpenCL/vendors" clinfo
|
---|
176 |
|
---|
177 | Unlike Vulkan, OpenCL takes a path to the whole ``vendors`` folder and will
|
---|
178 | enumerate any drivers found there.
|
---|
179 |
|
---|
180 | Troubleshooting local builds
|
---|
181 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
---|
182 |
|
---|
183 | If you are trying to run an app against a local build and it's not working,
|
---|
184 | here are a few things to check:
|
---|
185 |
|
---|
186 | 1. Double-check your paths and try with the simplest app you can. Before
|
---|
187 | banging your head on a Steam game, make sure your path works with
|
---|
188 | ``glxgears`` first.
|
---|
189 |
|
---|
190 | 2. Watch out for wrapper scripts. Some more complex apps such as games have
|
---|
191 | big start-up scripts. Sometimes those scripts scrub the environment or set
|
---|
192 | ``LD_LIBRARY_PATH`` to something in the game's install directory.
|
---|
193 |
|
---|
194 | 3. Is your Mesa build the same arch as your app? Lots of games are still
|
---|
195 | 32-bit and your Mesa build is probably 64-bit by default.
|
---|
196 |
|
---|
197 | 4. 32 and 64-bit builds in the same local install directory doesn't typically
|
---|
198 | work. Distributions go to great lengths to make this work in your system
|
---|
199 | install and it's hard to get it right for a local install. If you've
|
---|
200 | recently built 64-bit and are now building 32-bit, throw away the install
|
---|
201 | directory first to prevent conflicts.
|
---|
202 |
|
---|
203 | 1. Building with AOSP (Android)
|
---|
204 | -------------------------------
|
---|
205 |
|
---|
206 | <TODO>
|
---|
207 |
|
---|
208 | 1. Library Information
|
---|
209 | ----------------------
|
---|
210 |
|
---|
211 | When compilation has finished, look in the top-level ``lib/`` (or
|
---|
212 | ``lib64/``) directory. You'll see a set of library files similar to
|
---|
213 | this:
|
---|
214 |
|
---|
215 | .. code-block:: console
|
---|
216 |
|
---|
217 | lrwxrwxrwx 1 brian users 10 Mar 26 07:53 libGL.so -> libGL.so.1*
|
---|
218 | lrwxrwxrwx 1 brian users 19 Mar 26 07:53 libGL.so.1 -> libGL.so.1.5.060100*
|
---|
219 | -rwxr-xr-x 1 brian users 3375861 Mar 26 07:53 libGL.so.1.5.060100*
|
---|
220 | lrwxrwxrwx 1 brian users 14 Mar 26 07:53 libOSMesa.so -> libOSMesa.so.6*
|
---|
221 | lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSMesa.so.6.1.060100*
|
---|
222 | -rwxr-xr-x 1 brian users 23871 Mar 26 07:53 libOSMesa.so.6.1.060100*
|
---|
223 |
|
---|
224 | **libGL** is the main OpenGL library (i.e. Mesa), while **libOSMesa** is
|
---|
225 | the OSMesa (Off-Screen) interface library.
|
---|
226 |
|
---|
227 | If you built the DRI hardware drivers, you'll also see the DRI drivers:
|
---|
228 |
|
---|
229 | .. code-block:: console
|
---|
230 |
|
---|
231 | -rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i915_dri.so
|
---|
232 | -rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i965_dri.so
|
---|
233 | -rwxr-xr-x 1 brian users 11849858 Jul 21 12:12 r200_dri.so
|
---|
234 | -rwxr-xr-x 1 brian users 11757388 Jul 21 12:12 radeon_dri.so
|
---|
235 |
|
---|
236 | If you built with Gallium support, look in lib/gallium/ for
|
---|
237 | Gallium-based versions of libGL and device drivers.
|
---|
238 |
|
---|
239 | 1. Building OpenGL programs with pkg-config
|
---|
240 | -------------------------------------------
|
---|
241 |
|
---|
242 | Running ``meson install`` will install package configuration files for
|
---|
243 | the pkg-config utility.
|
---|
244 |
|
---|
245 | When compiling your OpenGL application you can use pkg-config to
|
---|
246 | determine the proper compiler and linker flags.
|
---|
247 |
|
---|
248 | For example, compiling and linking a GLUT application can be done with:
|
---|
249 |
|
---|
250 | .. code-block:: console
|
---|
251 |
|
---|
252 | gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo
|
---|