[FrontPage] [TitleIndex] [WordIndex

This guide is an alternative guide of how to compile mesa libGL library for 3D rendering

First of all I assume that you got at least basic 2D rendering working. If you don't you really should work on this first.

First create a directory to put all sources to it, for example say ~/software/graphics/

 mkdir ~/software/
 mkdir ~/software/graphics/
 cd ~/software/graphics/

I hope that step is obivous to you anyway, if not, you can learn about console for example at ubuntu's console howto

Also make sure you have git version control system installed, On Ubuntu systems its in 'git-core' package (beware of package 'git' which doesn't contain the git we talk about)

 sudo apt-get install git-core

Now install latest libdrm.

This step is usually necessarily because distributions typically lag behing libdrm that is necessarily to succesfully compile and use nouveau libGL.

Libdrm is the glue between kernel module and userspace and it is used by X driver and mesa to send via kernel command streams to GPU. Updating libdrm can in theory break your X as it also uses it. In practice it shouldn't happen, unless you have very old 2D nouveau driver.

First download libdrm using git from its official repostry:

 git clone git://anongit.freedesktop.org/git/mesa/drm

This will create a directory named 'drm' in our current directory. (please refer to TODO:$GIT_GUIDE to for other git related questions) So enter it

 cd drm

note that I won't be repeating the last step as you should understand that by now for reasons I stated above

Now configure it:

./autogen.sh --enable-nouveau-experimental-api --disable-intel --disable-radeon --prefix=/usr/local

The former step will almost for sure fail, as usually you will be missing dependencies (that is libraries this library uses). Sadly this differs between distros. On Ubuntu, the list of dependencies is:

If you have tough problem with configuring look at config.log. configure process mostly consists of compiling short test programs and testings that compile succeeded. If it fails, you'll see the log in that file. Look at it toward the end. Usually you will need the -dev package (-devel on some other distros) for a missing component.

Now compile it:

 make -j2

-j2 says it to use 2 compile jobs and thus faster on dual core CPUs. If you have 4 core or more substitute with number of cores. Note that this setting is purly optional.

And install it:

 sudo make install

That will install the library into special directory /usr/local (thats the --prefix we specified, remember?) that exists for the purpose of overrinding distro's packages safely. Usually you can't remove distro's libGL because too many packages depend on it, and it depends on distro's libdrm.

If you ever need to remove the installed files just go into that directory and remove files from it. Its not that easy, but knowing that it _only_ holds files you compiled its usually small enough to find and remove everything you don't want.

Note Some braindead distros (I am looking at you Arch linux, although I am not Ubuntu fan!) don't use libraries from /usr/local/lib. To make them see these libraries (libdrm in our case) add /usr/local/lib/ as a first line of /etc/ld.so.conf then run 'ldconfig' as root.

Compiling mesa OpenGL library

Mesa OpenGL library is the library that provides 3d acceleration on Linux. It includes the Gallium3D, which is an modern intermediate layer between user facing API of the library and the driver code. Its included in mesa source tree.

Once again enter the main directory (~/software/graphics/) Download mesa source the same way we did download libdrm once again from official repostry.

git clone git://git.freedesktop.org/git/mesa/mesa

Download dependencies (these are listed in ubuntu's package, your distro will have sligtly different package names..., but overall idea is same):

Configure it:

./autogen.sh                                            \
                                                        \
       --prefix=/usr/local/lib/mesa/                    \
       --with-dri-driverdir=/usr/local/lib/mesa/        \
       --with-gallium-drivers="nouveau"                 \
       --enable-debug                                   \
       --enable-texture-float                           \
                                                        \
                                                        \
       --with-dri-drivers=""                            \
       --disable-egl                                    \
       --disable-glu                                    \
       --disable-gallium-llvm                           \

Description of options:

Now compile it in same way and install (ok, last time I repeat that...) and install it.

 make -j2
 sudo make install

Now add /usr/local/lib/mesa/lib as first line of /etc/ld.so.conf and run ldconfig after that. Run 'ldd $(which glxgears)' and hope it says that libGL from mesa is used. We found out that on Arch linux its libGL which located in /usr/lib is always prefered over the one we install, so you have no choice but to remove it (and not rename it, as ldconfig is too smart for that...) You can instead of removing to move the libGL* files to different directory though.

And enjoy your latest mesa!


2013-03-24 13:16