Difference between revisions of "Cross compiling Mesa for Windows"

From Qt Wiki
Jump to: navigation, search
Line 1: Line 1:
=Cross compiling Mesa for Windows=
+
[[Category:Windows]]<br />[[Category:Qt5]]
  
QtQuick 2.0 applications require OpenGL 2.1 or higher to run. Windows only provides OpenGL 1.1 by default, which is not sufficient. One workaround is to use <span class="caps">ANGLE</span> which implements the OpenGL ES 2 <span class="caps">API</span> on top of DirectX 9. The benefit of using <span class="caps">ANGLE</span> is that the graphics are hardware-accelerated but <span class="caps">ANGLE</span> requires Windows Vista or later. The other option is to use a software renderer such as Mesa which can run on Windows XP or later and may perform better than <span class="caps">ANGLE</span> when running inside virtual machines.
+
= Cross compiling Mesa for Windows =
  
This article describes the process of cross-compiling Mesa for Windows on Arch Linux. The result is an opengl32.dll <span class="caps">DLL</span> that you can copy to the folder containing your application’s executable to use Mesa <span class="caps">LLVM</span>pipe software rendering.
+
QtQuick 2.0 applications require OpenGL 2.1 or higher to run. Windows only provides OpenGL 1.1 by default, which is not sufficient. One workaround is to use ANGLE which implements the OpenGL ES 2 API on top of DirectX 9. The benefit of using ANGLE is that the graphics are hardware-accelerated but ANGLE requires Windows Vista or later. The other option is to use a software renderer such as Mesa which can run on Windows XP or later and may perform better than ANGLE when running inside virtual machines.
  
Cross compiling is currently the only method that can compile the latest versions of Mesa for Windows using <span class="caps">GCC</span>. Compiling Mesa natively on Windows using <span class="caps">GCC</span> with Scons results in “the command line is too long” error during linking. There are known issues when compiling Mesa with optimizations using Visual Studio 2010. Compiling with Visual Studio 2012 is possible but requires Windows 7 and the default platform target does not support Windows XP. It is possible to cross compile using Cygwin or [[MSYS2]] Scons.
+
This article describes the process of cross-compiling Mesa for Windows on Arch Linux. The result is an opengl32.dll DLL that you can copy to the folder containing your application's executable to use Mesa LLVMpipe software rendering.
  
Prebuilt binaries for Mesa are available from the MSYS2 project:
+
Cross compiling is currently the only method that can compile the latest versions of Mesa for Windows using GCC. Compiling Mesa natively on Windows using GCC with Scons results in &quot;the command line is too long&amp;quot; error during linking. There are known issues when compiling Mesa with optimizations using Visual Studio 2010. Compiling with Visual Studio 2012 is possible but requires Windows 7 and the default platform target does not support Windows XP. It is possible to cross compile using Cygwin or [[MSYS2]] Scons.
  
* [http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/i686/mingw-w64-i686-mesa-10.0.2-1-any.pkg.tar.xz Mesa 10.0.2 for Windows 32-bit binary] ''[downloads.sourceforge.net]''
+
Prebuilt binaries for Mesa are available from the MSYS2 project:<br />* &quot;Mesa 10.0.2 for Windows 32-bit binary&amp;quot;:http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/i686/mingw-w64-i686-mesa-10.0.2-1-any.pkg.tar.xz<br />* &quot;Mesa 10.0.2 for Windows 64-bit binary&amp;quot;:http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/x86_64/mingw-w64-x86_64-mesa-10.0.2-1-any.pkg.tar.xz
* [http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/x86_64/mingw-w64-x86_64-mesa-10.0.2-1-any.pkg.tar.xz Mesa 10.0.2 for Windows 64-bit binary] ''[downloads.sourceforge.net]''
 
  
==Install required Arch Linux packages==
+
== Install required Arch Linux packages ==
  
==Compiling for Windows 32-bit==
+
<code><br />sudo pacman -S base-devel mingw-w64-toolchain libxml2 python2 scons<br /></code>
  
===Create a working directory for build===
+
== Compiling for Windows 32-bit ==
  
===Download <span class="caps">LLVM</span> and Mesa sources===
+
=== Create a working directory for build ===
  
===Extract sources===
+
<code><br />mkdir <sub>/mesa_win32<br />cd</sub>/mesa_win32<br /></code>
  
==Build <span class="caps">LLVM</span>==
+
=== Download LLVM and Mesa sources ===
  
Note: Use of the strerror_s function is disabled by writing an entry to config.cache for Windows XP compatibility.
+
<code><br />wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz<br />wget ftp://ftp.freedesktop.org/pub/mesa/10.0.2/MesaLib-10.0.2.tar.bz2<br /></code>
  
===Build Mesa===
+
=== Extract sources ===
  
===Complete===
+
<code><br />tar -xvf llvm-3.4.src.tar.gz<br />tar -xvf MesaLib-10.0.2.tar.bz2<br /></code>
  
You can now copy opengl32.dll from the ~/mesa_win32/dist folder to the folder containing your application’s executable.<br /> Your Qt must be compiled with Desktop OpenGL to use opengl32.dll. The <span class="caps">ANGLE</span> build will not load the mesa library.
+
== Build LLVM ==
  
==Compiling for Windows 64-bit==
+
<code><br />cd <sub>/mesa_win32/llvm-3.4<br />export PYTHON=/usr/bin/python2<br />mkdir build<br />cd build<br />echo 'ac_cv_have_decl_strerror_s=${ac_cv_have_decl_strerror_s=no}' &gt; config.cache<br />../configure -C —prefix=$HOME/mesa_win32/llvm-3.4.build —host=i686-w64-mingw32 —enable-optimized —disable-assertions —disable-pthreads —enable-targets=x86 —enable-bindings=none —disable-libffi —with-c-include-dirs=/usr/i686-w64-mingw32 —with-gcc-toolchain=/usr/i686-w64-mingw32 —with-default-sysroot=/usr/i686-w64-mingw32<br />make<br />make install<br /></code>
 +
<br />Note: Use of the strerror_s function is disabled by writing an entry to config.cache for Windows XP compatibility.
 +
<br />h3. Build Mesa
 +
<br /><code><br />cd</sub>/mesa_win32/Mesa-10.0.2<br />export LLVM=$HOME/mesa_win32/llvm-3.4.build<br />LDFLAGS=&quot;-static -s&amp;quot; scons build=release platform=windows toolchain=crossmingw machine=x86 libgl-gdi<br />mkdir <sub>/mesa_win32/dist<br />cp -a build/windows-x86/gallium/targets/libgl-gdi/opengl32.dll</sub>/mesa_win32/dist/<br /></code>
  
===Create a working directory for build===
+
=== Complete ===
  
===Download <span class="caps">LLVM</span> and Mesa sources===
+
You can now copy opengl32.dll from the <sub>/mesa_win32/dist folder to the folder containing your application's executable.<br />Your Qt must be compiled with Desktop OpenGL to use opengl32.dll. The ANGLE build will not load the mesa library.
 
+
<br />h2. Compiling for Windows 64-bit
===Extract sources===
+
<br />h3. Create a working directory for build
 
+
<br /><code><br />mkdir</sub>/mesa_win64<br />cd <sub>/mesa_win64<br /></code>
==Build <span class="caps">LLVM</span>==
+
<br />h3. Download LLVM and Mesa sources
 +
<br /><code><br />wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz<br />wget ftp://ftp.freedesktop.org/pub/mesa/10.0.2/MesaLib-10.0.2.tar.bz2<br /></code>
 +
<br />h3. Extract sources
 +
<br /><code><br />tar -xvf llvm-3.4.src.tar.gz<br />tar -xvf MesaLib-10.0.2.tar.bz2<br /></code>
 +
<br />h2. Build LLVM
 +
<br /><code><br />cd</sub>/mesa_win64/llvm-3.4<br />export PYTHON=/usr/bin/python2<br />mkdir build<br />cd build<br />echo 'ac_cv_have_decl_strerror_s=${ac_cv_have_decl_strerror_s=no}' &gt; config.cache<br />../configure -C —prefix=$HOME/mesa_win64/llvm-3.4.build —host=x86_64-w64-mingw32 —enable-optimized —disable-assertions —disable-pthreads —enable-targets=x86_64 —enable-bindings=none —disable-libffi —with-c-include-dirs=/usr/x86_64-w64-mingw32 —with-gcc-toolchain=/usr/x86_64-w64-mingw32 —with-default-sysroot=/usr/x86_64-w64-mingw32<br />make<br />make install<br /></code>
  
 
Note: Use of the strerror_s function is disabled by writing an entry to config.cache for Windows XP x64 compatibility.
 
Note: Use of the strerror_s function is disabled by writing an entry to config.cache for Windows XP x64 compatibility.
  
===Build Mesa===
+
=== Build Mesa ===
 
 
===Complete===
 
 
 
You can now copy opengl32.dll from the ~/mesa_win64/dist folder to the folder containing your application’s executable.<br /> Your Qt must be compiled with Desktop OpenGL to use opengl32.dll. The <span class="caps">ANGLE</span> build will not load the mesa library.
 
 
 
===Categories:===
 
  
* [[:Category:MinGW|MinGW]]
+
<code><br />cd <sub>/mesa_win64/Mesa-10.0.2<br />LDFLAGS=&quot;-static -s&amp;quot; scons build=release platform=windows toolchain=crossmingw machine=x86_64 libgl-gdi<br />mkdir</sub>/mesa_win64/dist<br />cp -a build/windows-x86_64/gallium/targets/libgl-gdi/opengl32.dll <sub>/mesa_win64/dist/<br /></code>
* [[:Category:Qt5|Qt5]]
+
<br />h3. Complete
* [[:Category:Windows|Windows]]
+
<br />You can now copy opengl32.dll from the</sub>/mesa_win64/dist folder to the folder containing your application's executable.

Revision as of 12:45, 23 February 2015


Cross compiling Mesa for Windows

QtQuick 2.0 applications require OpenGL 2.1 or higher to run. Windows only provides OpenGL 1.1 by default, which is not sufficient. One workaround is to use ANGLE which implements the OpenGL ES 2 API on top of DirectX 9. The benefit of using ANGLE is that the graphics are hardware-accelerated but ANGLE requires Windows Vista or later. The other option is to use a software renderer such as Mesa which can run on Windows XP or later and may perform better than ANGLE when running inside virtual machines.

This article describes the process of cross-compiling Mesa for Windows on Arch Linux. The result is an opengl32.dll DLL that you can copy to the folder containing your application's executable to use Mesa LLVMpipe software rendering.

Cross compiling is currently the only method that can compile the latest versions of Mesa for Windows using GCC. Compiling Mesa natively on Windows using GCC with Scons results in "the command line is too long&quot; error during linking. There are known issues when compiling Mesa with optimizations using Visual Studio 2010. Compiling with Visual Studio 2012 is possible but requires Windows 7 and the default platform target does not support Windows XP. It is possible to cross compile using Cygwin or MSYS2 Scons.

Prebuilt binaries for Mesa are available from the MSYS2 project:
* "Mesa 10.0.2 for Windows 32-bit binary&quot;:http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/i686/mingw-w64-i686-mesa-10.0.2-1-any.pkg.tar.xz
* "Mesa 10.0.2 for Windows 64-bit binary&quot;:http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/x86_64/mingw-w64-x86_64-mesa-10.0.2-1-any.pkg.tar.xz

Install required Arch Linux packages


sudo pacman -S base-devel mingw-w64-toolchain libxml2 python2 scons

Compiling for Windows 32-bit

Create a working directory for build


mkdir /mesa_win32
cd
/mesa_win32

Download LLVM and Mesa sources


wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz
wget ftp://ftp.freedesktop.org/pub/mesa/10.0.2/MesaLib-10.0.2.tar.bz2

Extract sources


tar -xvf llvm-3.4.src.tar.gz
tar -xvf MesaLib-10.0.2.tar.bz2

Build LLVM


cd /mesa_win32/llvm-3.4
export PYTHON=/usr/bin/python2
mkdir build
cd build
echo 'ac_cv_have_decl_strerror_s=${ac_cv_have_decl_strerror_s=no}' > config.cache
../configure -C —prefix=$HOME/mesa_win32/llvm-3.4.build —host=i686-w64-mingw32 —enable-optimized —disable-assertions —disable-pthreads —enable-targets=x86 —enable-bindings=none —disable-libffi —with-c-include-dirs=/usr/i686-w64-mingw32 —with-gcc-toolchain=/usr/i686-w64-mingw32 —with-default-sysroot=/usr/i686-w64-mingw32
make
make install

Note: Use of the strerror_s function is disabled by writing an entry to config.cache for Windows XP compatibility.
h3. Build Mesa

cd/mesa_win32/Mesa-10.0.2
export LLVM=$HOME/mesa_win32/llvm-3.4.build
LDFLAGS="-static -s&quot; scons build=release platform=windows toolchain=crossmingw machine=x86 libgl-gdi
mkdir /mesa_win32/dist
cp -a build/windows-x86/gallium/targets/libgl-gdi/opengl32.dll
/mesa_win32/dist/

Complete

You can now copy opengl32.dll from the /mesa_win32/dist folder to the folder containing your application's executable.
Your Qt must be compiled with Desktop OpenGL to use opengl32.dll. The ANGLE build will not load the mesa library.
h2. Compiling for Windows 64-bit
h3. Create a working directory for build

mkdir
/mesa_win64
cd /mesa_win64

h3. Download LLVM and Mesa sources

wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz
wget ftp://ftp.freedesktop.org/pub/mesa/10.0.2/MesaLib-10.0.2.tar.bz2

h3. Extract sources

tar -xvf llvm-3.4.src.tar.gz
tar -xvf MesaLib-10.0.2.tar.bz2

h2. Build LLVM

cd/mesa_win64/llvm-3.4
export PYTHON=/usr/bin/python2
mkdir build
cd build
echo 'ac_cv_have_decl_strerror_s=${ac_cv_have_decl_strerror_s=no}' > config.cache
../configure -C —prefix=$HOME/mesa_win64/llvm-3.4.build —host=x86_64-w64-mingw32 —enable-optimized —disable-assertions —disable-pthreads —enable-targets=x86_64 —enable-bindings=none —disable-libffi —with-c-include-dirs=/usr/x86_64-w64-mingw32 —with-gcc-toolchain=/usr/x86_64-w64-mingw32 —with-default-sysroot=/usr/x86_64-w64-mingw32
make
make install

Note: Use of the strerror_s function is disabled by writing an entry to config.cache for Windows XP x64 compatibility.

Build Mesa


cd /mesa_win64/Mesa-10.0.2
LDFLAGS="-static -s&quot; scons build=release platform=windows toolchain=crossmingw machine=x86_64 libgl-gdi
mkdir
/mesa_win64/dist
cp -a build/windows-x86_64/gallium/targets/libgl-gdi/opengl32.dll /mesa_win64/dist/

h3. Complete
You can now copy opengl32.dll from the/mesa_win64/dist folder to the folder containing your application's executable.