I am trying to compile and install mesa3D from source. (ftp://ftp.freedesktop.org/pub/mesa/11.0.0/mesa-11.0.0-rc3.tar.gz)

I am at the configure step

./configure \
--disable-xvmc \
--disable-glx \
--disable-dri \
--with-dri-drivers="" \
--with-gallium-drivers="swrast" \
--enable-texture-float \
--disable-shared-glapi \
--disable-egl \
--with-egl-platforms="" \
--enable-gallium-osmesa \
--enable-gallium-llvm=yes \
--with-llvm-shared-libs \

I keep getting the error about configure not finding the LIBDRM library

checking for LIBDRM... no
configure: error: shared GLAPI required when building two or more of
                      the following APIs - opengl, gles1 gles2

Even though the library is known to ldconfig

ldconfig -p | grep drm
libdrm_radeon.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1
libdrm_radeon.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdrm_radeon.so
libdrm_nouveau.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.1
libdrm_nouveau.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so
libdrm_intel.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdrm_intel.so.1
libdrm_intel.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdrm_intel.so
libdrm.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdrm.so.2
libdrm.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdrm.so

I tried to use the LDFLAGS env variable but without success

LDFLAGS='-L/usr/lib/x86_64-linux-gnu/' ./configure <my configure parameters here>


export LDFLAGS="-L/usr/lib/x86_64-linux-gnu/" && ./configure <my configure parameters here> 

Here is the part in the configure script (that I assume is) generating this error

# Check for libdrm

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBDRM" >&5
$as_echo_n "checking for LIBDRM... " >&6; }

if test -n "$LIBDRM_CFLAGS"; then
 elif test -n "$PKG_CONFIG"; then
    if test -n "$PKG_CONFIG" && \
    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= \$LIBDRM_REQUIRED\""; } >&5
  ($PKG_CONFIG --exists --print-errors "libdrm >= $LIBDRM_REQUIRED") 2>&5
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then
  pkg_cv_LIBDRM_CFLAGS=`$PKG_CONFIG --cflags "libdrm >= $LIBDRM_REQUIRED" 2>/dev/null`
                      test "x$?" != "x0" && pkg_failed=yes

Could you provide some propositions or hints to solve this problem?


  • 1
    Do you have the -dev package installed for opengl, gles1, or gles2?
    – John
    Mar 22, 2016 at 18:25
  • Nope. I am new to computer graphics, but from what I've read, mesa3D is an implementation of OpenGL (en.wikipedia.org/wiki/OpenGL#Implementations). It is mostly used to render 3D graphics using processors where no openGL drivers are provided by hardware vendors
    – LokmanDz
    Mar 22, 2016 at 18:41

3 Answers 3


Libraries seen by ldconfig are used for runtime linking; compiling requires an extra symlink (and header files in most cases). In this instance you need to install libdrm-dev, and probably other -dev packages too.

You may find How to build mesa useful; it explains in detail how to build Mesa from source in Debian.

  • That is true. ldconfig are used for run-time linking, thanks for the precision. Still, this shows that libdrm is well installed. As you have mentioned, I had to add symlink by exporting two env variables used by configure; LIBDRM_CFLAGS and LIBDRM_LIBS to compile mesa successfully.
    – LokmanDz
    Mar 23, 2016 at 13:20

The run-time libraries are installed, but per your comment response, the development packages are not - that's what the ./configure error is complaining about. I'm not sure of the exact package name, you'll probably have to do an apt-cache search for it, but if you install the -dev package for libDRM, that should resolve this issue. You may run into another -dev package not installed error, just keep installing the required -dev packages until the ./configure run completes.

  • As in my comment back to John, I don't think I need to install an OpenGL package, because that is exactly what I am trying to configure and install from source. Mesa3D is an actual implementation of OpenGL interface.
    – LokmanDz
    Mar 23, 2016 at 13:25
  • @LokmanDz you don't need to install OpenGL packages, but you do need to install the development packages for Mesa's dependencies. (Look for "adep" on packages.debian.org/source/unstable/mesa or just run sudo apt-get build-dep mesa.) Mar 23, 2016 at 13:30
  • You're correct - I was getting confused in re-reading the initial post. You do, however, need to install development packages for the DRM libraries. I'll modify this answer to reflect that shortly.
    – John
    Mar 23, 2016 at 13:30

Here is how I manged to install Mesa3D from source on Debian.Thanks to all people's answers and comments.

First, I had to install libdrm-dev package.

# apt-get install libdrm-dev

Then, check where the header and lib files were installed

# dpkg-query -L libdrm-dev

After that, export two env variables needed by configure to link to libdrm (https://stackoverflow.com/questions/24644211/mesa3d-install-cant-find-libdrm)

# export LIBDRM_CFLAGS="-I/usr/include/libdrm/"
# export LIBDRM_LIBS="-L/usr/lib/x86_64-linux-gnu/"

Finaly,configure, make and make install

# ./configure <parameters here>
# make -j24 # running on a 24 cores machine
# make -j24 install

Otherwise, the second error I was getting,

configure: error: shared GLAPI required when building two or more of
                  the following APIs - opengl, gles1 gles2

was not linked to libdrm. It was because of libgalpi that shouldn't be disabled when running configure!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.