This is a basic guide to building DRI from source. This guide only covers building the client-side 3D drivers. Since the transition to the modular X.org build, building an X-server and 2D drivers is beyond the scope of this document. That information can be found in the X.org Modular Developer Guide. An important aspect is to compile X-server with the
--with-mesa-source=/path/to/mesa option, to include glx/OpenGL support. You will most probably need to (re)compile also at least the keyboard and mouse drivers, in addition to a video card 2D driver.
KDrive servers are not supported at this time. Please report any problems with these instructions on the dri-users mailing list or on IRC.
The 2D drivers with DRI support, server-side GLX support and the GL library capable of loading DRI 3D drivers are developed in X.org's CVS. The 3D drivers, though, live in the Mesa tree, so you will have to check out the Mesa git tree. You should also get the DRM git tree for up-to-date kernel modules. The following instructions will guide you through the process step by step.
Warning: In case you didn't notice, you are about to compile and install experimental software. This will allow you to test the latest features and bug fixes. It may, however, also introduce new bugs. Be prepared for problems every now and then.
You need a current version (7.4, ie. xserver 1.5 as of this writing) of X.org (core and development packages) installed on your system. In particular, you need these X.org components:
- proto/glproto 1.4.14 or
- dri2proto 2.6 or
If you are using Debian or Ubuntu you can install the packages with:
apt-get build-dep libdrm mesa apt-get install linux-headers-`uname -r` apt-get install libxi-dev libxmu-dev x11proto-xf86vidmode-dev apt-get install git-core autoconf automake libtool
Get the source trees using two
git commands. These commands should be run in the same directory. When they've run, you will have two new subdirectories:
The clean DRM source tree takes about 4MB of disk space.
git clone git://anongit.freedesktop.org/git/mesa/drm
The clean Mesa source tree takes about 32MB of disk space.
git clone git://anongit.freedesktop.org/git/mesa/mesa
The Mesa drivers now require
libdrm to be installed. Do the following to build
cd drm ./autogen.sh
libdrm installs to
/usr/local/lib by default. To install in
Now you're ready to compile it:
Then as root, to install:
The DRI 3D drivers are now built from the Mesa source.
cd mesa ./autogen.sh
mesa installs to
/usr/local/lib by default. To install in
Choose the right configure options depending on the hardware architecture you're compiling for.
See http://www.mesa3d.org/autoconf.html for more information about configuring mesa or read the output from:
Note: You will need to install
libdrm for Mesa to build properly. You should have done that at step 1.3 when doing the "make install".
Note: You will need to update PKG_CONFIG_PATH if you installed
/usr/local/lib. For example,
Now you're ready to compile it:
After compiling the Mesa tree, the 3D drivers can be found in
mesa/lib. There are two ways of using them: installing them in the destined place, or telling X where to find them.
- Install the drivers to
Run as root, to install:
Or set the environment variable LIBGL_DRIVERS_PATH to point to
<path to Mesa>/lib, and also preload the newly built
/lib export LD_PRELOAD= /lib/libGL.so.1
To make these settings persistent, you'll have to add them to
.bashrc or a similar login script.
The DRM is shipped with the kernel on both Linux and FreeBSD, so you shouldn't have to build it explicitly. If you want to build it or develop it, the kernel building and development rules apply.
There are two things you have to do if you compiled X.org for the first time and were using XFree86 before. There should be a symbolic link
/etc/X11/X that points to
/usr/X11R6/bin/XFree86. You should make that link point to
cd /etc/X11 mv X X.backup ln -s /usr/X11R6/bin/Xorg X
xorg.conf, and in this file change the keyboard driver from
Section "Input" # ... Driver "kbd" # ... EndSection
In order to activate 3D acceleration make sure your
xorg.conf is set up right. In particular, make sure the GLX and DRI modules are being loaded:
Section "Module" # ... Load "glx" Load "dri" # ... EndSection
and set the permissions for DRI appropriately. To allow anyone to use DRI, do:
Section "DRI" Mode 0666 EndSection
To restrict DRI access to a certain group, find on your system the name of the group that is for video hardware access. (Have a look in
/etc/group. It is often called
video.) Add the users that may access the video hardware to that group. Then put this into
Section "DRI" Group "video" Mode 0660 EndSection
On Linux 2.4.x make sure the agpgart kernel module is loaded before you start X. On Linux 2.6.x make sure both agpgart and the agp chipset specific driver for your motherboard (via_agp, intel_agp, et al.) are loaded before you start X. To make the agp modules load automatically add these lines to your
pre-install <drm module> /sbin/modprobe "-k" "agpgart"
pre-install <drm module> /sbin/modprobe "-k" "agpgart" pre-install agpgart /sbin/modprobe "-k" "<agp chipset driver>"
For all kernels, make sure the DRM module is loaded before you start X.
Remember to restart X so the server will use the new modules.
If your issue isn't covered here, please report it on
#dri on IRC or on the dri-users mailing list. This section only covers build-time troubleshooting; for run-time issues see DriTroubleshooting.
FATAL: Error inserting via (/lib/modules/2.6.1/kernel/ drivers/char/drm/<module name>.ko): Unknown symbol in module, or unknown parameter (see dmesg)
This error occurs because there are some missing symbols in the 2.6.1 kernel source. One way to get around this problem is to upgrade your kernel to a newer version... (You might be able to patch the DRM code to avoid this... Not sure about this, though!)
You need to have the headers for your current X version installed. How you install these depends on how you installed X in the first place:
- If you downloaded a binary from xfree86.org, the headers are in
- For Slackware the package is called
- Redhat/Fedora and SuSE users should install the appropriate
- Mandrake calls this package
libxfree86-develfor some reason.
- Debian users should use
- Gentoo users only need to make sure
xorg-x11have already been emerged.
When building the kernel modules, the compilation might fail for some modules. In a recent CVS snapshot, I got the following:
savage_drv.c: In function `savage_alloc_continuous_mem': savage_drv.c:106: warning: passing arg 1 of `remap_page_range_Rc414bdc2' makes pointer from integer without a cast savage_drv.c:106: incompatible type for argument 4 of `remap_page_range_Rc414bdc2' savage_drv.c:106: too few arguments to function `remap_page_range_Rc414bdc2' savage_drv.c: In function `savage_get_physics_address': savage_drv.c:170: warning: implicit declaration of function `pte_offset' savage_drv.c:170: warning: assignment makes pointer from integer without a cast make: *** [savage_drv.o] Error 1
You can avoid this problem by only building the modules you need. See the DRM section above for the bit about the
xf86cfg requires libXaw (and appropriate headers) to be installed in order to build. You can either install the relevant packages for your distribution, or else add the line:
#define BuildXFree86ConfigTools NO
config/cf/host.def and rerun
ToDo: fill this in with package names, as above.
Gentoo has its own How-To on their website -- http://www.gentoo.org/doc/en/dri-howto.xml
For those who enabled DRI via the instructions here...
There is a known issue with Gentoo's Open
GL package switch; when the `opengl-update` package is installed, Gentoo places OpenGL libraries and header files under
/usr/lib/opengl and uses symlinks to make everything appear in the normal place. As a result the normal install process doesn't always work.
Try setting up a "fake" Open``GL package, and switch into it:
cd /usr/lib/opengl mkdir mesa-cvs cd mesa-cvs ln -s ../../../local/lib ln -s ../../../local/include ln -s ../xorg-x11/extensions opengl-update mesa-cvs
This assumes you installed Mesa (including lib
, which is the default. Also, you may like to remove everything in/usr/local/lib
from Mesa that isn't eitherlibGL.
-- things likelibGLw.*` can cause problems.
If you set things up differently, a way to check whether you are affected by
opengl-update is to strace any Open
`GL based program (for example:glxgears
) and to see whichlibGL.so
it loads. Despite all symlinks it should load/usr/lib/libGL.so.1.2
. If it doesn't correct the symlinks in/usr/lib
to point to/usr/lib/libGL.so.1.2
. After that **don't runopengl-update`** -- it will only break things.