2020-06-13 02:09:42 +08:00
|
|
|
Compiling and Installing
|
|
|
|
========================
|
|
|
|
|
2018-05-19 07:28:49 +08:00
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 1
|
|
|
|
:hidden:
|
|
|
|
|
|
|
|
meson
|
|
|
|
|
2020-06-13 02:09:42 +08:00
|
|
|
1. Prerequisites for building
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
1.1 General
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
Build system
|
|
|
|
^^^^^^^^^^^^
|
|
|
|
|
2024-01-03 01:17:28 +08:00
|
|
|
- `Meson <https://mesonbuild.com>`__ is required when building on \*nix
|
|
|
|
platforms and on Windows.
|
|
|
|
- Android Build system when building as native Android component. Meson
|
|
|
|
is used when building ARC.
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
Compiler
|
|
|
|
^^^^^^^^
|
|
|
|
|
|
|
|
The following compilers are known to work, if you know of others or
|
|
|
|
you're willing to maintain support for other compiler get in touch.
|
|
|
|
|
2024-01-03 01:17:28 +08:00
|
|
|
- GCC 8.0.0 or later (some parts of Mesa may require later versions)
|
|
|
|
- Clang 5.0 or later (some parts of Mesa may require later versions)
|
|
|
|
- Microsoft Visual Studio 2019 Version 16.11 or later and
|
|
|
|
Windows SDK of at least 20348 is required, for building on Windows.
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
Third party/extra tools.
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2024-01-03 01:17:28 +08:00
|
|
|
- `Python <https://www.python.org/>`__ - Python 3.6 or newer is required.
|
2024-01-03 01:21:10 +08:00
|
|
|
- Python package ``packaging`` is required on Python 3.12+:
|
|
|
|
``pip install packaging``
|
2024-01-03 01:17:28 +08:00
|
|
|
- `Python Mako module <https://www.makotemplates.org/>`__ - Python Mako
|
|
|
|
module is required. Version 0.8.0 or later should work.
|
|
|
|
- Lex / Yacc - for building the Mesa IR and GLSL compiler.
|
2020-06-13 02:09:42 +08:00
|
|
|
|
2020-09-30 00:26:25 +08:00
|
|
|
On Linux systems, Flex and Bison versions 2.5.35 and 2.4.1,
|
2020-06-13 02:09:42 +08:00
|
|
|
respectively, (or later) should work. On Windows with MinGW, install
|
2020-09-30 00:26:25 +08:00
|
|
|
Flex and Bison with:
|
2020-06-13 02:09:42 +08:00
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
mingw-get install msys-flex msys-bison
|
|
|
|
|
|
|
|
For MSVC on Windows, install `Win
|
2022-11-07 20:30:03 +08:00
|
|
|
flex-bison <https://sourceforge.net/projects/winflexbison/>`__.
|
2020-06-13 02:09:42 +08:00
|
|
|
|
2019-06-04 16:39:58 +08:00
|
|
|
.. note::
|
|
|
|
|
2020-09-30 21:24:01 +08:00
|
|
|
Some versions can be buggy (e.g. Flex 2.6.2) so do try others
|
2019-06-04 16:39:58 +08:00
|
|
|
if things fail.
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
1.2 Requirements
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The requirements depends on the features selected at configure stage.
|
2021-02-03 19:14:47 +08:00
|
|
|
Check/install the respective development package as prompted by the
|
|
|
|
configure error message.
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
Here are some common ways to retrieve most/all of the dependencies based
|
|
|
|
on the packaging tool used by your distro.
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
zypper source-install --build-deps-only Mesa # openSUSE/SLED/SLES
|
|
|
|
yum-builddep mesa # yum Fedora, OpenSuse(?)
|
|
|
|
dnf builddep mesa # dnf Fedora
|
|
|
|
apt-get build-dep mesa # Debian and derivatives
|
|
|
|
... # others
|
|
|
|
|
2023-03-24 23:10:54 +08:00
|
|
|
1. Building with meson
|
2020-06-13 02:09:42 +08:00
|
|
|
----------------------
|
|
|
|
|
|
|
|
Meson is the latest build system in mesa, it is currently able to build
|
|
|
|
for \*nix systems like Linux and BSD, macOS, Haiku, and Windows.
|
|
|
|
|
|
|
|
The general approach is:
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2020-06-13 02:09:42 +08:00
|
|
|
|
2023-02-22 23:43:57 +08:00
|
|
|
meson setup builddir/
|
2023-05-19 18:20:56 +08:00
|
|
|
meson compile -C builddir/
|
|
|
|
sudo meson install -C builddir/
|
2020-06-13 02:09:42 +08:00
|
|
|
|
2020-09-30 00:38:30 +08:00
|
|
|
On Windows you can also use the Visual Studio backend
|
2020-06-13 02:09:42 +08:00
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2020-06-13 02:09:42 +08:00
|
|
|
|
2023-02-22 23:43:57 +08:00
|
|
|
meson setup builddir --backend=vs
|
2020-06-13 02:09:42 +08:00
|
|
|
cd builddir
|
|
|
|
msbuild mesa.sln /m
|
|
|
|
|
2020-06-15 18:31:36 +08:00
|
|
|
Please read the :doc:`detailed meson instructions <meson>` for more
|
2020-06-13 02:09:42 +08:00
|
|
|
information
|
|
|
|
|
2023-03-24 23:10:54 +08:00
|
|
|
1. Running against a local build (easy way)
|
|
|
|
-------------------------------------------
|
2021-07-10 01:52:55 +08:00
|
|
|
|
|
|
|
It's often necessary or useful when debugging driver issues or testing new
|
|
|
|
branches to run against a local build of Mesa without doing a system-wide
|
2023-03-24 23:10:54 +08:00
|
|
|
install. Meson has built-in support for this with its ``devenv`` subcommand:
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2023-03-24 23:10:54 +08:00
|
|
|
|
|
|
|
meson devenv -C builddir glxinfo
|
|
|
|
|
|
|
|
This will run the given command against the build in ``builddir``. Note that meson
|
|
|
|
will ``chdir`` into the directory first, so any relative paths in the command line
|
|
|
|
will be relative to ``builddir`` which may not be what you expect.
|
|
|
|
|
|
|
|
1. Running against a local build (hard way)
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
If you prefer you can configure your test environment manually. To do this,
|
|
|
|
choose a temporary location for the install. A directory called ``installdir``
|
|
|
|
inside your mesa tree is as good as anything. All of the commands below will
|
|
|
|
assume ``$MESA_INSTALLDIR`` is an absolute path to this location.
|
2021-07-10 01:52:55 +08:00
|
|
|
|
|
|
|
First, configure Mesa and install in the temporary location:
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2021-07-10 01:52:55 +08:00
|
|
|
|
2023-02-22 23:43:57 +08:00
|
|
|
meson setup builddir/ -Dprefix="$MESA_INSTALLDIR" OTHER_OPTIONS
|
2023-05-19 18:20:56 +08:00
|
|
|
meson install -C builddir/
|
2021-07-10 01:52:55 +08:00
|
|
|
|
|
|
|
where ``OTHER_OPTIONS`` is replaced by any meson configuration options you may
|
|
|
|
want. For instance, if you want to build the LLVMpipe drivers, it would look
|
|
|
|
like this:
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2021-07-10 01:52:55 +08:00
|
|
|
|
2023-02-22 23:43:57 +08:00
|
|
|
meson setup builddir/ -Dprefix="$MESA_INSTALLDIR" \
|
2021-07-10 01:52:55 +08:00
|
|
|
-Dgallium-drivers=swrast -Dvulkan-drivers=swrast
|
2023-05-19 18:20:56 +08:00
|
|
|
meson install -C builddir/
|
2021-07-10 01:52:55 +08:00
|
|
|
|
|
|
|
Once Mesa has built and installed to ``$MESA_INSTALLDIR``, you can run any app
|
|
|
|
against your temporary install by setting the right environment variables.
|
|
|
|
Which variable you have to set depends on the API.
|
|
|
|
|
|
|
|
OpenGL
|
|
|
|
~~~~~~
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2021-07-10 01:52:55 +08:00
|
|
|
|
|
|
|
LD_LIBRARY_PATH="$MESA_INSTALLDIR/lib64" glxinfo
|
|
|
|
|
|
|
|
You may need to use ``lib`` instead of ``lib64`` on some systems or a full
|
2024-06-25 01:02:55 +08:00
|
|
|
library specifier on Debian. Look inside ``installdir`` for the directory that
|
2021-07-10 01:52:55 +08:00
|
|
|
contains ``libGL.so`` and use that one.
|
|
|
|
|
|
|
|
Vulkan
|
|
|
|
~~~~~~
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2021-07-10 01:52:55 +08:00
|
|
|
|
2024-04-02 00:04:02 +08:00
|
|
|
VK_DRIVER_FILES="$MESA_INSTALLDIR/share/vulkan/icd/my_icd.json" vulkaninfo
|
2021-07-10 01:52:55 +08:00
|
|
|
|
|
|
|
where ``my_icd.json`` is replaced with the actual ICD json file name. This
|
2022-10-20 16:13:13 +08:00
|
|
|
will depend on your driver. For instance, the 64-bit Lavapipe driver ICD file
|
2021-07-10 01:52:55 +08:00
|
|
|
is named ``lvp_icd.x86_64.json``.
|
|
|
|
|
|
|
|
OpenCL
|
|
|
|
~~~~~~
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2021-07-10 01:52:55 +08:00
|
|
|
|
|
|
|
OCL_ICD_VENDORS="$MESA_INSTALLDIR/etc/OpenCL/vendors" clinfo
|
|
|
|
|
|
|
|
Unlike Vulkan, OpenCL takes a path to the whole ``vendors`` folder and will
|
|
|
|
enumerate any drivers found there.
|
|
|
|
|
|
|
|
Troubleshooting local builds
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
If you are trying to run an app against a local build and it's not working,
|
|
|
|
here are a few things to check:
|
|
|
|
|
|
|
|
1. Double-check your paths and try with the simplest app you can. Before
|
|
|
|
banging your head on a Steam game, make sure your path works with
|
|
|
|
``glxgears`` first.
|
|
|
|
|
|
|
|
2. Watch out for wrapper scripts. Some more complex apps such as games have
|
|
|
|
big start-up scripts. Sometimes those scripts scrub the environment or set
|
|
|
|
``LD_LIBRARY_PATH`` to something in the game's install directory.
|
|
|
|
|
|
|
|
3. Is your Mesa build the same arch as your app? Lots of games are still
|
|
|
|
32-bit and your Mesa build is probably 64-bit by default.
|
|
|
|
|
|
|
|
4. 32 and 64-bit builds in the same local install directory doesn't typically
|
2022-10-20 17:30:43 +08:00
|
|
|
work. Distributions go to great lengths to make this work in your system
|
|
|
|
install and it's hard to get it right for a local install. If you've
|
|
|
|
recently built 64-bit and are now building 32-bit, throw away the install
|
|
|
|
directory first to prevent conflicts.
|
2021-07-10 01:52:55 +08:00
|
|
|
|
2023-03-24 23:10:54 +08:00
|
|
|
1. Building with AOSP (Android)
|
2020-06-13 02:09:42 +08:00
|
|
|
-------------------------------
|
|
|
|
|
2021-06-08 00:40:11 +08:00
|
|
|
<TODO>
|
2020-06-13 02:09:42 +08:00
|
|
|
|
2023-03-24 23:10:54 +08:00
|
|
|
1. Library Information
|
2020-06-13 02:09:42 +08:00
|
|
|
----------------------
|
|
|
|
|
|
|
|
When compilation has finished, look in the top-level ``lib/`` (or
|
|
|
|
``lib64/``) directory. You'll see a set of library files similar to
|
|
|
|
this:
|
|
|
|
|
2024-01-11 19:15:25 +08:00
|
|
|
.. code-block:: text
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
lrwxrwxrwx 1 brian users 10 Mar 26 07:53 libGL.so -> libGL.so.1*
|
|
|
|
lrwxrwxrwx 1 brian users 19 Mar 26 07:53 libGL.so.1 -> libGL.so.1.5.060100*
|
|
|
|
-rwxr-xr-x 1 brian users 3375861 Mar 26 07:53 libGL.so.1.5.060100*
|
|
|
|
lrwxrwxrwx 1 brian users 14 Mar 26 07:53 libOSMesa.so -> libOSMesa.so.6*
|
|
|
|
lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSMesa.so.6.1.060100*
|
|
|
|
-rwxr-xr-x 1 brian users 23871 Mar 26 07:53 libOSMesa.so.6.1.060100*
|
|
|
|
|
|
|
|
**libGL** is the main OpenGL library (i.e. Mesa), while **libOSMesa** is
|
|
|
|
the OSMesa (Off-Screen) interface library.
|
|
|
|
|
|
|
|
If you built the DRI hardware drivers, you'll also see the DRI drivers:
|
|
|
|
|
2024-01-11 19:15:25 +08:00
|
|
|
.. code-block:: text
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
-rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i915_dri.so
|
|
|
|
-rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i965_dri.so
|
|
|
|
-rwxr-xr-x 1 brian users 11849858 Jul 21 12:12 r200_dri.so
|
|
|
|
-rwxr-xr-x 1 brian users 11757388 Jul 21 12:12 radeon_dri.so
|
|
|
|
|
|
|
|
If you built with Gallium support, look in lib/gallium/ for
|
|
|
|
Gallium-based versions of libGL and device drivers.
|
|
|
|
|
2023-03-24 23:10:54 +08:00
|
|
|
1. Building OpenGL programs with pkg-config
|
2020-06-13 02:09:42 +08:00
|
|
|
-------------------------------------------
|
|
|
|
|
2023-05-19 18:20:56 +08:00
|
|
|
Running ``meson install`` will install package configuration files for
|
2020-06-13 02:09:42 +08:00
|
|
|
the pkg-config utility.
|
|
|
|
|
|
|
|
When compiling your OpenGL application you can use pkg-config to
|
|
|
|
determine the proper compiler and linker flags.
|
|
|
|
|
|
|
|
For example, compiling and linking a GLUT application can be done with:
|
|
|
|
|
2024-01-11 19:16:00 +08:00
|
|
|
.. code-block:: sh
|
2020-06-13 02:09:42 +08:00
|
|
|
|
|
|
|
gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo
|