Personal tools
You are here: Home / cmgui / Wiki / Building Mesa library
Log in

Forgot your password?

Building Mesa library

The Mesa library is a free software graphics library which provides a generic OpenGL implementation and is required to build cmgui. You may also require Mesa to run cmgui if you do not have a hardware OpenGL implementation (eg if on a machine without a graphics card of if using a virtual machine).

The latest source code for the Mesa library can be downloaded from The MesaLib file is available as a tarball or zip file. The development releases are sometimes unstable, so it is safer to go with a stable release.

Once you have extracted the MesaLib file into a directory building the Mesa library is generally a simple process under most of the platforms. The user will only need to specify the OS name with the make command and the build process should be completed without much problem. eg for a x86 32 bit machine running linux you would change into the mesa directory and type 'make linux-x86-32'

The list of available platforms can be found by looking in the configs directory.

On Linux If you build Mesa and want to use the version you built you should set the LD_LIBRARY_PATH environment variable to point to your Mesa lib directory. Add a line to your .bashrc file so that you don't have to manually export it each time. eg:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/cmiss/mesa/Mesa-7.2/lib

Compilation problem with AIX

However I did encounter a problem when I compiled the Mesa library for AIX(rs6000-AIX) and here is the error message that I received: "ld: 0711-317 ERROR: Undefined symbol: .__builtin_expect".

To fix this problem, I removed the macro for IBMC compiler in the src/mesa/main/glheader.h file (thanks Shane for pointing this out). However this will not fix the problem completely, the compilation will still fail. To compile the library successfully, I ran the make command inside the src folder and now the lib files will be built inside the lib folder.

Compiling Mesa for Windows with MinGW

Mesa comes with makefiles titles 'Makefile.mgw' for building with MinGW. Following is what worked for me; if you find a way to build it conveniently for mingw under cygwin, please document this!

  1. Install MinGW with the appropriate compilers plus mingw32-make. If running on Vista, note there is a defect in current mingw32 compilers ('cannot exec cc1plus : No such file or directory') which requires patched versions - google 'cc1plus vista mingw'.
  2. Open a Windows command window (needed for DOS copy/del commands invoked from makefiles), and set up paths and environment (Following for MinGW installed under D:MinGW):
set path=D:MinGWbin;%PATH% set LIBRARY_PATH=D:MinGWlib set C_INCLUDE_PATH=D:MinGWinclude set CPLUS_INCLUDE_PATH=D:MinGWincludec++3.4.5;D:MinGWincludec++3.4.5backward;D:MinGWincludec++mingw32;D:MinGWinclude
  1. Change to your mesa folder and invoke the make file:
mingw32-make -f Makefile.mgw
  1. Copy the 'include' and 'lib' folder contents to the following locations expected by cmgui (in my case '{CMISS_ROOT}' is 'd:cmiss'):

Compiling Mesa for Windows using cross-compiler in Linux

Compiling MESA for windows in Linux requires a cross-platform mingw gcc compiler. To compile MESA, user needs to change the Makefile.mgw script at different part in the src folder in the MESA source code to specify a cross-compiler. In our current build system we have a win32 make script called i386-mingw32-cross-make which uses win32 compilers including i386-mingw32msvc-gcc. Therefore to build the library I change a line in the Makefile.mgw from:

{default} TOOLS_PREFIX = mingw32-
{edited}  TOOLS_PREFIX = i386-mingw32msvc-