The Problem Domain

We have multiple, often hardware dependent, implementations of the Khronos EGL, GL|ES, and OpenVG APIs. We want software in the Ubuntu archive to be able to build against these APIs. Software in the Ubuntu archive must build against the Mesa implementation.

With the introduction of MultiArch support in dpkg we should also support the parallel install of EGL packages from different sources for different architectures - for example, to allow a developer on an x86-64 system to use the x86-64 EGL implementation from the proprietary ATI drivers while having an armel EGL implementation from mesa installed to cross-compile for ARM.

The goal is to have multiple EGL implementations available in the Ubuntu archive


  • The selection of EGL implementation determines which GL|ES and OpenVG implementation is usable. For example, it would never be useful to use a vendor's GLESv2 library with Mesa's EGL.
  • The libraries (with SONAME) are,, and



This is a brief summary as it applies to EGL libraries. See the MultiarchSpec for full details.

Throughout this guide DEB_HOST_MULTIARCH is used as a variable. The appropriate value for this variable on an Ubuntu system can be found by running dpkg-architecture -qDEB_HOST_MULTIARCH. The most common values for DEB_HOST_MULTIARCH are arm-linux-gnueabi for armel, i386-linux-gnu for i386, and x86_64-linux-gnu for amd64.

If vendor drivers are only available for a single architecture then the rest of this section may be skipped. The traditional /usr/lib library paths still function as normal on a multiarch system, and there is no technical impediment to switching to multiarch packaging later.

To allow for the same package built for different architectures to be installed at the same time the library paths must be unique for each architecture (dpkg has special handling for data in /usr/share). Libraries for a multi-arch ready EGL package must live in a subdirectory of /usr/lib/$DEB_HOST_MULTIARCH/. The value of DEB_HOST_MULTIARCH can be retrieved with from dpkg-architecture -qDEB_HOST_MULTIARCH. For example, libraries for the amd64 architecture live in /usr/lib/x86_64-linux-gnu/.

There is (at the moment) no equivalent policy for -dev packages.


To support FIXME the previous Conflicts/Provides/Replaces solution is no longer appropriate as it precludes having the Mesa EGL libraries for one architecture and a vendor's EGL libraries for the native architecture simultaneously installed. We instead use the Debian alternatives system to provide a per-architecture switch.

Packages which use this alternatives system should not provide the libegl1-x11, libgles1, libgles2 or libopenvg1 virtual packages.

Each EGL implementation should install their libraries into a subdirectory of libdir, which should be of the form $VENDOR-egl. The implementation should also install a file, containing the fully qualified directory name. For example, on x86-64, Mesa's implementation is installed into /usr/lib/x86_64-linux-gnu/mesa-egl, and has a /usr/lib/x86_64-linux-gnu/mesa-egl/ file containing the line


The current EGL implementation is selected by setting the $DEB_HOST_MULTIARCH_egl_conf alternative. This alternative will set /etc/$DEB_HOST_MULTIARCH_EGL.conf to point to the current implementation's The dynamic loader will then search the implementation's private libdir when attempting to resolve libraries.

The package which provides is responsible for setting the alternative. If the GL|ES or OpenVG libraries are in separate packages, they should be installed alongside and should not touch the alternatives configuration.

debian/rules example snippet

        # Create an which says where to find libEGL, libGLES{1,2} 
        # and libOpenVG from Mesa.

        echo "/usr/lib/$(DEB_HOST_MULTIARCH)/mesa-egl" \
        > $(CURDIR)/debian/libegl1-mesa/usr/lib/$(DEB_HOST_MULTIARCH)/mesa-egl/

postinst example

set -e


case "$1" in
  # Use alternatives to make it easier to switch between Mesa and 3rd party modules
  update-alternatives --force \
    --install /etc/${DEB_HOST_MULTIARCH}_EGL.conf ${DEB_HOST_MULTIARCH}_egl_conf /usr/lib/${DEB_HOST_MULTIARCH}/mesa-egl/ 500 \

  # ldconfig needs to be run immediately as we're changing /etc/ with
  # alternatives.



exit 0

prerm example

set -e


case "$1" in
  # Use alternatives to make it easier to switch between Mesa and 3rd party modules
  update-alternatives --remove ${DEB_HOST_MULTIARCH}_egl_conf /usr/lib/${DEB_HOST_MULTIARCH}/mesa-egl/

  # explicit ldconfig due to alternatives



exit 0


  • A vendor's libraries must be installed into a private library path. This will typically be of the form /usr/lib/$VENDOR-egl or /usr/lib/$DEB_HOST_MULTIARCH/$VENDOR-egl.

  • The vendor packages must include an file in their private library path. This file should consist of a single line of text, containing the private library path as an absolute path. This means the file will typically contain a path of the form



  • The vendor packages must add an ${DEB_HOST_MULTIARCH}_EGL_conf alternative to their snippet in their postinst maintainer script and remove this alternative in their prerm maintainer script. The alternative should be added at a higher priority than the Mesa alternative (which has a priority of 500).

  • A package using this alternatives scheme must not Provide: any of the libegl1-x11, libgles1, libgles2 or libopenvg1 virtual packages.

  • A vendor's EGL/GL|ES/OpenVG implementation should be contained in a single package. There is no facility for resolving application dependencies to specific packages in a vendor's implementation. If the vendor also ships an Xorg DDX and/or OpenGL implementation, these may all be shipped as a single package. Note however that OpenGL implementations require additional integration work not covered in this document.

Mesa provides the following EGL binary packages:

  • libegl1-mesa (containing /usr/lib/$DEB_HOST_MULTIARCH/mesa-egl/

  • libegl1-mesa-dev (containing /usr/include/EGL, /usr/include/KHR, and the→ symlink.)

  • libopenvg1-mesa (containing /usr/lib/$DEB_HOST_MULTIARCH/mesa-egl/

  • libopenvg1-mesa-dev (containing /usr/include/VG and the→ symlink.)

  • libgles1-mesa (containing /usr/lib/$DEB_HOST_MULTIARCH/mesa-egl/

  • libgles1-mesa-dev (containing /usr/include/GLES and the→ symlink.)

  • libgles2-mesa (containing /usr/lib/$DEB_HOST_MULTIARCH/mesa-egl/

  • libgles2-mesa-dev (containing /usr/include/GLES2 and the→ symlink.)

X/EGLDriverPackagingHOWTO (last edited 2011-07-22 04:47:17 by raof)