Home > Linux, Programming, Video > Cross-Compiling Mesa 3D Graphics Library for ARM

Cross-Compiling Mesa 3D Graphics Library for ARM

Mesa is an open-source implementation of the OpenGL specification that can be used for software emulation or  complete hardware acceleration for modern GPUs.The Mesa library is used by a variety of games (e.g. Quake 2.3), libraries (e.g PyOpenGL), science and technical applications and utilities (e.g. xscreensaver).

MesaLib requires X11 libraries. I’ll assume those are already cross-compiled here. For this build, I used pre-built X11 libraries found in ALIP (ARM Internet Platform) binaries. I used the method described here and copied the libs in /lib and /usr/lib and header files in /lib/include found in the qemu overo image respectively to /home/jaufranc/edeve/beagleboard/libs/lib and /home/jaufranc/edeve/beagleboard/libs/include. make sure you use the “-d” with cp to avoid copying the symlinks or some symbolic links would point to x86 binaries or files that do not exist.

Here are the instructions to cross-compile MesaLib 7.11 for ARM using arm-linux-guneabi-gcc:

  1. Download the latest version of Mesa source code:
    wget ftp://ftp.freedesktop.org/pub/mesa/7.11/MesaLib-7.11.tar.bz2
  2. Extract the source code
    tar xjvf MesaLib-7.11.tar.bz2
    cd Mesa-7.11
  3. Install the following packages (makedepend is part of xutils-dev):
    sudo apt-get install xutils-dev flex bison xorg-dev llvm
  4. Download, build and install libdrm 2.4.26:
    wget http://dri.freedesktop.org/libdrm/libdrm-2.4.26.tar.bz2
    tar xvjf libdrm-2.4.26.tar.bz2
    cd libdrm-2.4.26
    ./configure
    make
    sudo make install
  5. There seems to be a problem with libdrm make install, so we also need to copy some extra header files manually:
    sudo cp nouveau/*.h /usr/include/drm/
  6. Configure and build Mesa for x86.
    cd ../Mesa-7.11
    ./configure
    make

    You do not actually need to build the full MesaLib at this point, you could interrupt the build after builtin_compiler is built.

  7. Save a copy of builtin_compiler and glsl_compiler:
    cd src/glsl
    cp builtin_compiler builtin_compiler_x86
  8. Clean the source directory:
    cd ../..
    make distclean
  9. Start build Mesa for ARM:
    CFLAGS="-I/usr/include" \
    X11_LIBS="-L/home/jaufranc/edev/beagleboard/libs/lib/arm-linux-gnueabi \
    -lX11" X11_INCLUDES="-I/usr/include" X11_CFLAGS="-I/usr/include" ./configure \
    --target=arm-linux-gnueabi --host=arm-linux-gnueabi --prefix=/home/jaufranc/edev/beagleboard/libs \
    --includedir=/home/jaufranc/edev/beagleboard/libs/include/ \
    --libdir=/home/jaufranc/edev/beagleboard/libs/lib/arm-linux-gnueabi \
    --libdir=/home/jaufranc/edev/beagleboard/libs/lib
    make

    This should end with an error while building builtin_compiler.

  10. Then copy builtin_compiler_x86 back to builtin_compiler
    cd src/glsl
    cp builtin_compiler_x86 builtin_compiler
  11. Edit the config file configs/current to add the library paths for GL as follows:
    GL_LIB_DEPS = $(EXTRA_LIB_PATH) -L/home/jaufranc/edev/beagleboard/libs/lib/arm-linux-gnueabi \ -L/usr/arm-linux-gnueabi/lib/ -lX11 -lXext    -lm -lpthread -ldl
  12. And keep building:
    make
    make install

This was tested in Ubuntu 11.04 (natty) and 10.04 LTS with linaro gcc toolchain.

N.B: If your platform does not use X11 and just want to do off-screen rendering, you can build Mesa on linux with:

make linux-osmesa

 

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Categories: Linux, Programming, Video Tags: arm, cross-compilation, mesa, opengl, ubuntu
  1. Alex
    April 29th, 2013 at 18:21 | #1

    Hello,
    when i excute this tutorial, i am in the 6 steps Configure and build Mesa for x86.

    ./configure
    make

    i get this eroors
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_pushbuf_flush’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_bo_pending’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_pushbuf_marker_undo’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_grobj_autobind’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_pushbuf_marker_emit’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_bo_unmap’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_channel_free’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_grobj_free’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_device_open_existing’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_pushbuf_emit_reloc’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_device_close’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_channel_alloc’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_bo_handle_get’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_bo_map’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_bo_new’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_bo_ref’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_bo_handle_ref’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_notifier_alloc’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_bo_new_tile’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_grobj_alloc’
    nouveau_vieux_dri.so.tmp: undefined reference to `nouveau_notifier_free’
    collect2: ld returned 1 exit status
    make[6]: *** [nouveau_vieux_dri.so] Error 1

    Please Help ME and thank you :)

  1. No trackbacks yet.