1848b8605Smrg<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2848b8605Smrg<html lang="en"> 3848b8605Smrg<head> 4848b8605Smrg <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5848b8605Smrg <title>Compiling and Installing</title> 6848b8605Smrg <link rel="stylesheet" type="text/css" href="mesa.css"> 7848b8605Smrg</head> 8848b8605Smrg<body> 9848b8605Smrg 10848b8605Smrg<div class="header"> 11848b8605Smrg <h1>The Mesa 3D Graphics Library</h1> 12848b8605Smrg</div> 13848b8605Smrg 14848b8605Smrg<iframe src="contents.html"></iframe> 15848b8605Smrg<div class="content"> 16848b8605Smrg 17848b8605Smrg<h1>Compiling and Installing</h1> 18848b8605Smrg 19848b8605Smrg<ol> 20848b8605Smrg<li><a href="#prereq-general">Prerequisites for building</a> 21848b8605Smrg <ul> 22848b8605Smrg <li><a href="#prereq-general">General prerequisites</a> 23848b8605Smrg <li><a href="#prereq-dri">For DRI and hardware acceleration</a> 24848b8605Smrg </ul> 25b8e80941Smrg<li><a href="#meson">Building with meson</a> 26848b8605Smrg<li><a href="#autoconf">Building with autoconf (Linux/Unix/X11)</a> 27848b8605Smrg<li><a href="#scons">Building with SCons (Windows/Linux)</a> 28b8e80941Smrg<li><a href="#android">Building with AOSP (Android)</a> 29848b8605Smrg<li><a href="#libs">Library Information</a> 30848b8605Smrg<li><a href="#pkg-config">Building OpenGL programs with pkg-config</a> 31848b8605Smrg</ol> 32848b8605Smrg 33848b8605Smrg 34848b8605Smrg<h1 id="prereq-general">1. Prerequisites for building</h1> 35848b8605Smrg 36848b8605Smrg<h2>1.1 General</h2> 37b8e80941Smrg 38b8e80941Smrg<p> 39b8e80941SmrgBuild system. 40b8e80941Smrg</p> 41b8e80941Smrg 42848b8605Smrg<ul> 43b8e80941Smrg<li><a href="https://mesonbuild.com">meson</a> is required when building on *nix platforms. 44b8e80941Smrg<li>Autoconf was removed in 19.1.0, use meson instead 45848b8605Smrg<li><a href="http://www.scons.org/">SCons</a> is required for building on 46b8e80941SmrgWindows and optional for Linux (it's an alternative to meson.) 47848b8605Smrg</li> 48b8e80941Smrg<li>Android Build system when building as native Android component. Autoconf 49b8e80941Smrgis used when when building ARC. 50848b8605Smrg</li> 51848b8605Smrg</ul> 52848b8605Smrg 53848b8605Smrg 54b8e80941Smrg<p> 55b8e80941SmrgThe following compilers are known to work, if you know of others or you're 56b8e80941Smrgwilling to maintain support for other compiler get in touch. 57b8e80941Smrg</p> 58b8e80941Smrg 59b8e80941Smrg<ul> 60b8e80941Smrg<li>GCC 4.2.0 or later (some parts of Mesa may require later versions) 61b8e80941Smrg<li>clang - exact minimum requirement is currently unknown. 62b8e80941Smrg<li>Microsoft Visual Studio 2015 or later is required, for building on Windows. 63b8e80941Smrg</ul> 64b8e80941Smrg 65848b8605Smrg 66848b8605Smrg<p> 67b8e80941SmrgThird party/extra tools. 68b8e80941Smrg<br> 69b8e80941Smrg<strong>Note</strong>: These should not be required, when building from a release tarball. If 70b8e80941Smrgyou think you've spotted a bug let developers know by filing a 71b8e80941Smrg<a href="bugs.html">bug report</a>. 72848b8605Smrg</p> 73848b8605Smrg 74b8e80941Smrg 75848b8605Smrg<ul> 76b8e80941Smrg<li><a href="https://www.python.org/">Python</a> - Python is required. 77b8e80941SmrgWhen building with scons 2.7 is required. 78b8e80941SmrgWhen building with meson 3.5 or newer is required. 79b8e80941Smrg</li> 80b8e80941Smrg<li><a href="http://www.makotemplates.org/">Python Mako module</a> - 81b8e80941SmrgPython Mako module is required. Version 0.8.0 or later should work. 82b8e80941Smrg</li> 83b8e80941Smrg<li>lex / yacc - for building the Mesa IR and GLSL compiler. 84b8e80941Smrg<div> 85b8e80941SmrgOn Linux systems, flex and bison versions 2.5.35 and 2.4.1, respectively, 86b8e80941Smrg(or later) should work. 87b8e80941SmrgOn Windows with MinGW, install flex and bison with: 88b8e80941Smrg<pre>mingw-get install msys-flex msys-bison</pre> 89b8e80941SmrgFor MSVC on Windows, install 90b8e80941Smrg<a href="http://winflexbison.sourceforge.net/">Win flex-bison</a>. 91b8e80941Smrg</div> 92848b8605Smrg</ul> 93b8e80941Smrg<p><strong>Note</strong>: Some versions can be buggy (eg. flex 2.6.2) so do try others if things fail.</p> 94b8e80941Smrg 95b8e80941Smrg 96b8e80941Smrg<h3 id="prereq-dri">1.2 Requirements</h3> 97b8e80941Smrg 98848b8605Smrg<p> 99b8e80941SmrgThe requirements depends on the features selected at configure stage. 100b8e80941SmrgCheck/install the respective -devel package as prompted by the configure error 101b8e80941Smrgmessage. 102848b8605Smrg</p> 103848b8605Smrg 104b8e80941Smrg<p> 105b8e80941SmrgHere are some common ways to retrieve most/all of the dependencies based on 106b8e80941Smrgthe packaging tool used by your distro. 107b8e80941Smrg</p> 108848b8605Smrg 109b8e80941Smrg<pre> 110b8e80941Smrg zypper source-install --build-deps-only Mesa # openSUSE/SLED/SLES 111b8e80941Smrg yum-builddep mesa # yum Fedora, OpenSuse(?) 112b8e80941Smrg dnf builddep mesa # dnf Fedora 113b8e80941Smrg apt-get build-dep mesa # Debian and derivatives 114b8e80941Smrg ... # others 115b8e80941Smrg</pre> 116848b8605Smrg 117b8e80941Smrg<h1 id="meson">2. Building with meson</h1> 118848b8605Smrg 119848b8605Smrg<p> 120b8e80941SmrgMeson is the latest build system in mesa, it is currently able to build for 121b8e80941Smrg*nix systems like Linux and BSD, and will be able to build for windows as well. 122848b8605Smrg</p> 123848b8605Smrg 124848b8605Smrg<p> 125b8e80941SmrgThe general approach is: 126848b8605Smrg</p> 127848b8605Smrg<pre> 128b8e80941Smrg meson builddir/ 129b8e80941Smrg ninja -C builddir/ 130b8e80941Smrg sudo ninja -C builddir/ install 131848b8605Smrg</pre> 132848b8605Smrg<p> 133b8e80941SmrgPlease read the <a href="meson.html">detailed meson instructions</a> 134b8e80941Smrgfor more information 135b8e80941Smrg</p> 136b8e80941Smrg 137b8e80941Smrg<h1 id="autoconf">3. Building with autoconf (Linux/Unix/X11)</h1> 138b8e80941Smrg 139b8e80941Smrg<p> 140b8e80941Smrg Autoconf support was removed in Mesa 19.1.0. Please use meson instead. 141848b8605Smrg</p> 142848b8605Smrg 143848b8605Smrg 144848b8605Smrg 145b8e80941Smrg<h1 id="scons">4. Building with SCons (Windows/Linux)</h1> 146848b8605Smrg 147848b8605Smrg<p> 148848b8605SmrgTo build Mesa with SCons on Linux or Windows do 149848b8605Smrg</p> 150848b8605Smrg<pre> 151848b8605Smrg scons 152848b8605Smrg</pre> 153848b8605Smrg<p> 154848b8605SmrgThe build output will be placed in 155848b8605Smrgbuild/<i>platform</i>-<i>machine</i>-<i>debug</i>/..., where <i>platform</i> is for 156848b8605Smrgexample linux or windows, <i>machine</i> is x86 or x86_64, optionally followed 157848b8605Smrgby -debug for debug builds. 158848b8605Smrg</p> 159848b8605Smrg 160848b8605Smrg<p> 161848b8605SmrgTo build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do 162848b8605Smrg</p> 163848b8605Smrg<pre> 164b8e80941Smrg scons platform=windows toolchain=crossmingw machine=x86 libgl-gdi 165848b8605Smrg</pre> 166848b8605Smrg<p> 167848b8605SmrgThis will create: 168848b8605Smrg</p> 169848b8605Smrg<ul> 170b8e80941Smrg<li>build/windows-x86-debug/gallium/targets/libgl-gdi/opengl32.dll — Mesa + Gallium + softpipe (or llvmpipe), binary compatible with Windows's opengl32.dll 171848b8605Smrg</ul> 172848b8605Smrg<p> 173848b8605SmrgPut them all in the same directory to test them. 174b8e80941Smrg 175b8e80941SmrgAdditional information is available in <a href="README.WIN32">README.WIN32</a>. 176b8e80941Smrg 177848b8605Smrg</p> 178848b8605Smrg 179848b8605Smrg 180848b8605Smrg 181b8e80941Smrg<h1 id="android">5. Building with AOSP (Android)</h1> 182848b8605Smrg 183848b8605Smrg<p> 184b8e80941SmrgCurrently one can build Mesa for Android as part of the AOSP project, yet 185b8e80941Smrgyour experience might vary. 186848b8605Smrg</p> 187848b8605Smrg 188b8e80941Smrg<p> 189b8e80941SmrgIn order to achieve that one should update their local manifest to point to the 190b8e80941Smrgupstream repo, set the appropriate BOARD_GPU_DRIVERS and build the 191b8e80941SmrglibGLES_mesa library. 192b8e80941Smrg</p> 193848b8605Smrg 194b8e80941Smrg<p> 195b8e80941SmrgFINISHME: Improve on the instructions add references to Rob H repos/Jenkins, 196b8e80941SmrgAndroid-x86 and/or other resources. 197b8e80941Smrg</p> 198848b8605Smrg 199848b8605Smrg 200b8e80941Smrg<h1 id="libs">6. Library Information</h1> 201848b8605Smrg 202848b8605Smrg<p> 203848b8605SmrgWhen compilation has finished, look in the top-level <code>lib/</code> 204848b8605Smrg(or <code>lib64/</code>) directory. 205848b8605SmrgYou'll see a set of library files similar to this: 206848b8605Smrg</p> 207848b8605Smrg<pre> 208b8e80941Smrglrwxrwxrwx 1 brian users 10 Mar 26 07:53 libGL.so -> libGL.so.1* 209b8e80941Smrglrwxrwxrwx 1 brian users 19 Mar 26 07:53 libGL.so.1 -> libGL.so.1.5.060100* 210848b8605Smrg-rwxr-xr-x 1 brian users 3375861 Mar 26 07:53 libGL.so.1.5.060100* 211b8e80941Smrglrwxrwxrwx 1 brian users 14 Mar 26 07:53 libOSMesa.so -> libOSMesa.so.6* 212b8e80941Smrglrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSMesa.so.6.1.060100* 213848b8605Smrg-rwxr-xr-x 1 brian users 23871 Mar 26 07:53 libOSMesa.so.6.1.060100* 214848b8605Smrg</pre> 215848b8605Smrg 216848b8605Smrg<p> 217848b8605Smrg<b>libGL</b> is the main OpenGL library (i.e. Mesa). 218848b8605Smrg<br> 219848b8605Smrg<b>libOSMesa</b> is the OSMesa (Off-Screen) interface library. 220848b8605Smrg</p> 221848b8605Smrg 222848b8605Smrg<p> 223848b8605SmrgIf you built the DRI hardware drivers, you'll also see the DRI drivers: 224848b8605Smrg</p> 225848b8605Smrg<pre> 226848b8605Smrg-rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i915_dri.so 227848b8605Smrg-rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i965_dri.so 228848b8605Smrg-rwxr-xr-x 1 brian users 11849858 Jul 21 12:12 r200_dri.so 229848b8605Smrg-rwxr-xr-x 1 brian users 11757388 Jul 21 12:12 radeon_dri.so 230848b8605Smrg</pre> 231848b8605Smrg 232848b8605Smrg<p> 233848b8605SmrgIf you built with Gallium support, look in lib/gallium/ for Gallium-based 234848b8605Smrgversions of libGL and device drivers. 235848b8605Smrg</p> 236848b8605Smrg 237848b8605Smrg 238b8e80941Smrg<h1 id="pkg-config">7. Building OpenGL programs with pkg-config</h1> 239848b8605Smrg 240848b8605Smrg<p> 241b8e80941SmrgRunning <code>ninja install</code> will install package configuration files 242848b8605Smrgfor the pkg-config utility. 243848b8605Smrg</p> 244848b8605Smrg 245848b8605Smrg<p> 246848b8605SmrgWhen compiling your OpenGL application you can use pkg-config to determine 247848b8605Smrgthe proper compiler and linker flags. 248848b8605Smrg</p> 249848b8605Smrg 250848b8605Smrg<p> 251848b8605SmrgFor example, compiling and linking a GLUT application can be done with: 252848b8605Smrg</p> 253848b8605Smrg<pre> 254848b8605Smrg gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo 255848b8605Smrg</pre> 256848b8605Smrg 257848b8605Smrg<br> 258848b8605Smrg 259848b8605Smrg</div> 260848b8605Smrg</body> 261848b8605Smrg</html> 262