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:
- Download the latest version of Mesa source code:
- Extract the source code
Shell12tar xjvf MesaLib-7.11.tar.bz2cd Mesa-7.11
- Install the following packages (makedepend is part of xutils-dev):
Shell1sudo apt-get install xutils-dev flex bison xorg-dev llvm
- Download, build and install libdrm 2.4.26:
Shell123456wget http://dri.freedesktop.org/libdrm/libdrm-2.4.26.tar.bz2tar xvjf libdrm-2.4.26.tar.bz2cd libdrm-2.4.26./configuremakesudo make install
- There seems to be a problem with libdrm make install, so we also need to copy some extra header files manually:
Shell1sudo cp nouveau/*.h /usr/include/drm/
- Configure and build Mesa for x86.
You do not actually need to build the full MesaLib at this point, you could interrupt the build after builtin_compiler is built.
- Save a copy of builtin_compiler and glsl_compiler:
Shell12cd src/glslcp builtin_compiler builtin_compiler_x86
- Clean the source directory:
Shell12cd ../..make distclean
- Start build Mesa for ARM:
Shell12345678CFLAGS="-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/libmake
This should end with an error while building builtin_compiler.
- Then copy builtin_compiler_x86 back to builtin_compiler
Shell12cd src/glslcp builtin_compiler_x86 builtin_compiler
- Edit the config file configs/current to add the library paths for GL as follows:
Shell1GL_LIB_DEPS = $(EXTRA_LIB_PATH) <strong>-L/home/jaufranc/edev/beagleboard/libs/lib/arm-linux-gnueabi \ -L/usr/arm-linux-gnueabi/lib/</strong> -lX11 -lXext -lm -lpthread -ldl
- And keep building:
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:
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
|Support CNX Software - Donate via PayPal or become a Patron on Patreon|