Building Mesa for windows 7. Mesa 9.1

c, mesa, opengl, python

Solution

Common `scons` options:

build=release
machine=x86
platform=windows
libgl-gdi

Linux (Debian Wheezy), `toolchain=crossmingw`: Fails during linking phase because it can't find `__vscprintf`, among other things. Works as of Debian Jessie 8.5 & Mesa `d2f42a945ec0fbcc51b59cfd329258bd62ebf0d2` via:

scons \
toolchain=crossmingw \
build=release \
machine=x86 \
platform=windows \
libgl-gdi

DLL is installed to `build/windows-x86/gallium/targets/libgl-gdi/opengl32.dll`

Windows, `toolchain=mingw`: Fails with "The command line is too long." despite multiple permutations of both snippits on `LongCmdLinesOnWin32`.

Windows, VS2012 Express, `MSVC_VERSION=11.0`: Succeeds after removing stray C99-isms from `src/glsl/ralloc.c::ralloc_size()`.

EDIT: More complete procedure:

Install Visual Studio Express 2012 for Windows Desktop:

http://www.microsoft.com/visualstudio/eng/downloads#d-express-windows-desktop

Install MinGW:

http://www.mingw.org/
http://sourceforge.net/projects/mingw/files/
http://sourceforge.net/projects/mingw/files/latest/download?source=files
mingw-get-inst-20120426.exe

Run installer:
Download latest repo catalogs
Install to C:\MinGW (default)
Check:
* C compiler
* C++ compiler
* MSYS basic system
* MinGW developer toolkit (should install msys-flex and msys-bison)

Install Python 2.7:

http://www.python.org/download/
http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi

You have to use 32-bit Python because the Scons people only distribute 32-bit installers.

Install for all users (default)
Install to C:\Python27 (default)
Use default install options/customizations

Install `libxml2` for Python:

http://www.lfd.uci.edu/~gohlke/pythonlibs/
libxml2-python-2.9.1.win32-py2.7.‌exe

Installer should find the python install automagically

Install `pywin32`:

http://pywin32.sourceforge.net/
http://sourceforge.net/projects/pywin32/files/pywin32/
http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/
http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe

Installer should find the Python install automagically

Install `Scons`:

http://www.scons.org/
http://prdownloads.sourceforge.net/scons/scons-2.3.0-setup.exe

Installer should find the Python install automagically

Add these near the top of your `PATH`:

C:\Python27\
C:\Python27\Scripts

Download Mesa:

ftp://ftp.freedesktop.org/pub/mesa/
ftp://ftp.freedesktop.org/pub/mesa/9.1.5/MesaLib-9.1.5.zip

Extract somewhere (C:\Mesa-9.1.5)

Start MSYS shell:

C:\mingw\msys\1.0\msys.bat

Change into mesa src directory:
cd /c/Mesa-9.1.5/

Build Mesa:

scons.py \
build=release \
machine=x86 \
platform=windows \
MSVC_VERSION=11.0 \
libgl-gdi \

This should create an `opengl32.dll` in `build\windows-x86\gallium\targets\libgl-gdi`.

With a little bit more legwork it's possible to build `llvmpipe`.

Problem

I went through all the steps on the compiling / installing page on Mesa's site, and read the FAQ. The final command that you send to scons for compilation throws errors within python scripts. This is my output. What am I doing wrong? Also if anyone has compiled dll's for mesa using up to date mesa and mingw, or VS2012, then please share! Here is my output, I haven't programmed python in a long time but it appears a map/dictionary doesn't contain the key/value pair. ``` C:\Downloads\MesaLib-9.1.5\Mesa-9.1.5>scons platform=windows toolchain=crossming w machine=x86_64 mesagdi libgl-gdi scons: Reading SConscript files ... KeyError: 'CCVERSION': File "C:\Downloads\MesaLib-9.1.5\Mesa-9.1.5\SConstruct", line 40: ENV = os.environ, File "C:\Python27\scons-2.3.0\SCons\Environment.py", line 1002: apply_tools(self, tools, toolpath) File "C:\Python27\scons-2.3.0\SCons\Environment.py", line 106: env.Tool(tool) File "C:\Python27\scons-2.3.0\SCons\Environment.py", line 1786: tool(self) File "C:\Python27\scons-2.3.0\SCons\Tool\__init__.py", line 183: self.generate(env, *args, **kw) File "C:\Downloads\MesaLib-9.1.5\Mesa-9.1.5\scons\gallium.py", line 313: ccversion = env['CCVERSION'] File "C:\Python27\scons-2.3.0\SCons\Environment.py", line 412: return self._dict[key] ```

Original source