Discussion:
[Mesa-dev] Building Mesa for Windows using Visual Studio
Shervin Sharifi
2015-03-25 01:00:48 UTC
Permalink
Hi,
I'm new to Mesa.
I'm trying to build Mesa for Windows using Visual Studio, but couldn't
find instructions for that. The related threads on this mailing list also
seem outdated.
Could anyone give me some hint or point me to instructions if there is
any?

Thanks,
Shervin
Jose Fonseca
2015-03-25 09:59:16 UTC
Permalink
See

http://www.mesa3d.org/install.html

or docs/install.html from Mesa tree.


If you want to build with llvmpipe support, you'll also need to read and
follow

http://www.mesa3d.org/llvmpipe.html


I'm also experimenting on automated Windows builds with AppVeyor. You
can see the build logs on

https://ci.appveyor.com/project/jrfonseca/mesa


Jose
Post by Shervin Sharifi
Hi,
I'm new to Mesa.
I'm trying to build Mesa for Windows using Visual Studio, but couldn't
find instructions for that. The related threads on this mailing list
also seem outdated.
Could anyone give me some hint or point me to instructions if there is
any?
Thanks,
Shervin
_______________________________________________
mesa-dev mailing list
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=AwIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=KwlxC7fWLwmVmiUUTznYf2r7emIl5UqECVgWWjHL0dA&s=cfjvYkqjebZsPUkVyHAtSlKGP4Y12qExxEQPEqFLoWI&e=
Predut, Marius
2015-04-03 12:34:16 UTC
Permalink
How I build mesa on windows:

1.install Microsoft vs 2013(not 2012 or less).

2.install last python 2.7 : https://www.python.org/downloads/
install pywin32 from http://heanet.dl.sourceforge.net/project/pywin32/pywin32/Build%20219/pywin32-219.win32-py2.7.exe
download win flex-bison from http://sourceforge.net/projects/winflexbison/
and unzip into c:\win_flex_bison

3.Environment settings.
Add these near the top of your PATH:
C:\Python27
C:\Python27\Scripts
c:\win_flex_bison
if you use proxy add FTP_PROXY and HTTP_PROXY env. variables.


4.install pip by downloading get-pip.py file from:
https://pip.pypa.io/en/latest/installing.html
and then run:
python get-pip.py --proxy="[user:passwd@]proxy.server:port"

5.Add mako, lxml and NumPy python modules by pip
pip install Mako
pip install lxml
pip install NumPy (not mandatory I think)

6.install scons from http://sourceforge.net/projects/scons/?source=typ_redirect


7.Build mesa:
scons build=release machine=x86 platform=windows libgl-gdi
or simple run: scons.
This should create an opengl32.dll in build\windows-x86\gallium\targets\libgl-gdi


OBS:

Why vs 2013 and not vs 2012:
the VS 2012 partially implement C++ TR1 C99 standard library already used into the latest upstream mesa.
(http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspx)
In vs 2012 the math.h don't include rint, rintf, rintl library support used in mesa even if the MSDN say contrary :
https://msdn.microsoft.com/nl-nl/dn465165.)
Mesa uses those API in mesa\src\util\rounding.h.

marius

From: mesa-dev [mailto:mesa-dev-***@lists.freedesktop.org] On Behalf Of Shervin Sharifi
Sent: Wednesday, March 25, 2015 3:01 AM
To: mesa-***@lists.freedesktop.org
Subject: [Mesa-dev] Building Mesa for Windows using Visual Studio

Hi,
I'm new to Mesa.
I'm trying to build Mesa for Windows using Visual Studio, but couldn't find instructions for that. The related threads on this mailing list also seem outdated.
Could anyone give me some hint or point me to instructions if there is any?

Thanks,
Shervin
Emil Velikov
2015-04-03 13:01:42 UTC
Permalink
Hi Marius.

Thank you for the write-up.
Post by Predut, Marius
1.install Microsoft vs 2013(not 2012 or less).
2.install last python 2.7 : https://www.python.org/downloads/
install pywin32 from
http://heanet.dl.sourceforge.net/project/pywin32/pywin32/Build%20219/pywin32-219.win32-py2.7.exe
download win flex-bison from http://sourceforge.net/projects/winflexbison/
and unzip into c:\win_flex_bison
3.Environment settings.
C:\Python27
C:\Python27\Scripts
c:\win_flex_bison
if you use proxy add FTP_PROXY and HTTP_PROXY env. variables.
https://pip.pypa.io/en/latest/installing.html
5.Add mako, lxml and NumPy python modules by pip
pip install Mako
pip install lxml
pip install NumPy (not mandatory I think)
6.install scons from
http://sourceforge.net/projects/scons/?source=typ_redirect
scons build=release machine=x86 platform=windows libgl-gdi
or simple run: scons.
This should create an opengl32.dll in
build\windows-x86\gallium\targets\libgl-gdi
the VS 2012 partially implement C++ TR1 C99 standard library already
used into the latest upstream mesa.
(http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspx)
In vs 2012 the math.h don't include rint, rintf, rintl library support
https://msdn.microsoft.com/nl-nl/dn465165.)
Mesa uses those API in mesa\src\util\rounding.h.
Just a couple of small details - mesa has a fall-back for the mentioned
functions (plus others) in $(top)/include/*h.

That said, I believe that the overall consensus is that building mesa
with MSVC 2008, is the bare minimum, with MSVC 2013 strongly
recommended. Afaik, as the VMWare guys give us the go ahead we'll drop
all the workarounds for pre-2013 versions and bump the requirement.

Cheers,
Emil
Predut, Marius
2015-04-03 13:43:46 UTC
Permalink
Just a couple of small details - mesa has a fall-back for the mentioned functions (plus others) in $(top)/include/*h.
That said, I believe that the overall consensus is that building mesa with MSVC 2008, is the bare minimum, with MSVC 2013 strongly recommended. Afaik, as the VMWare guys give us the go ahead > > > we'll drop all the workarounds for pre-2013 versions and bump the requirement.
Cheers,
Emil
Hmm, nice to know,
but in this case the build system have to take in consideration and this is a bug or ,
by hand we should copy headers?

Thanks for this info
marius
Emil Velikov
2015-04-03 14:01:22 UTC
Permalink
Post by Predut, Marius
Just a couple of small details - mesa has a fall-back for the mentioned functions (plus others) in $(top)/include/*h.
That said, I believe that the overall consensus is that building mesa with MSVC 2008, is the bare minimum, with MSVC 2013 strongly recommended. Afaik, as the VMWare guys give us the go ahead > > > we'll drop all the workarounds for pre-2013 versions and bump the requirement.
Cheers,
Emil
Hmm, nice to know,
but in this case the build system have to take in consideration and this is a bug or ,
by hand we should copy headers?
Not sure I fully understand your statement here. Currently there are
two types of headers - A) provide official (like) implementation, and
B) that wrap around existing ones.
Example:
A) include/c99/* provides stdint.h & co for MSVC 2012 and older as
they lack the headers.
B) include/c99_math.h provides compat wrapper, as MSVC 2013's math.h
is not in C99 land yet.

About using those - everything is handled already. Where needed the
extra include is added by the build (for A) and where the code is
known to be build with MSVC a header from B is used rather than the
system one.

Hope that clears things up.
Emil
Shervin Sharifi
2015-04-04 00:38:46 UTC
Permalink
Thank you for useful information.
I was able to build Mesa with VS 2013 with a similar scheme with scons.

Thanks,
Shervin
Post by Emil Velikov
Post by Predut, Marius
Post by Emil Velikov
Just a couple of small details - mesa has a fall-back for the mentioned
functions (plus others) in $(top)/include/*h.
Post by Predut, Marius
Post by Emil Velikov
That said, I believe that the overall consensus is that building mesa
with MSVC 2008, is the bare minimum, with MSVC 2013 strongly recommended.
Afaik, as the VMWare guys give us the go ahead > > > we'll drop all the
workarounds for pre-2013 versions and bump the requirement.
Post by Predut, Marius
Post by Emil Velikov
Cheers,
Emil
Hmm, nice to know,
but in this case the build system have to take in consideration and this
is a bug or ,
Post by Predut, Marius
by hand we should copy headers?
Not sure I fully understand your statement here. Currently there are
two types of headers - A) provide official (like) implementation, and
B) that wrap around existing ones.
A) include/c99/* provides stdint.h & co for MSVC 2012 and older as
they lack the headers.
B) include/c99_math.h provides compat wrapper, as MSVC 2013's math.h
is not in C99 land yet.
About using those - everything is handled already. Where needed the
extra include is added by the build (for A) and where the code is
known to be build with MSVC a header from B is used rather than the
system one.
Hope that clears things up.
Emil
Shervin Sharifi
2015-04-13 23:22:38 UTC
Permalink
Hi,
I tried to use Mesa (compiled with MSVC) to run OpenGL ES content on
Windows . I ran into a few problems.
I don't know if this is the right way of reporting issues, but thought
people may be interested to know.

Here's a piece of code in functions _mesa_dlopen(const char*, int) in
src\mesa\main\dlopen.h (same problem happens with function
_mesa_dlsym(void *, const char *) in the same file).

The original code returns NULL and doesn't load the library if the code is
compiled with Visual Studio.

#if defined(HAVE_DLOPEN)
flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */
return dlopen(libname, flags);
#elif defined(__MINGW32__)
return LoadLibraryA(libname);
#else
return NULL;
#endif

Adding the following lines to the code resolves the problem:

#elif defined(_WIN32)
return LoadLibraryA(libname);

Thanks,
Shervin
Post by Shervin Sharifi
Thank you for useful information.
I was able to build Mesa with VS 2013 with a similar scheme with scons.
Thanks,
Shervin
Post by Predut, Marius
Post by Emil Velikov
Just a couple of small details - mesa has a fall-back for the
mentioned functions (plus others) in $(top)/include/*h.
Post by Predut, Marius
Post by Emil Velikov
That said, I believe that the overall consensus is that building mesa
with MSVC 2008, is the bare minimum, with MSVC 2013 strongly recommended.
Afaik, as the VMWare guys give us the go ahead > > > we'll drop all the
workarounds for pre-2013 versions and bump the requirement.
Post by Predut, Marius
Post by Emil Velikov
Cheers,
Emil
Hmm, nice to know,
but in this case the build system have to take in consideration and
this is a bug or ,
Post by Predut, Marius
by hand we should copy headers?
Not sure I fully understand your statement here. Currently there are
two types of headers - A) provide official (like) implementation, and
B) that wrap around existing ones.
A) include/c99/* provides stdint.h & co for MSVC 2012 and older as
they lack the headers.
B) include/c99_math.h provides compat wrapper, as MSVC 2013's math.h
is not in C99 land yet.
About using those - everything is handled already. Where needed the
extra include is added by the build (for A) and where the code is
known to be build with MSVC a header from B is used rather than the
system one.
Hope that clears things up.
Emil
Emil Velikov
2015-04-14 12:41:06 UTC
Permalink
Hi Shervin,
Post by Shervin Sharifi
Hi,
I tried to use Mesa (compiled with MSVC) to run OpenGL ES content on
Windows . I ran into a few problems.
I don't know if this is the right way of reporting issues, but thought
people may be interested to know.
Another thing would be to file a bug report, although most people
appreciate patches (send via git send-email) even more :-)
Post by Shervin Sharifi
Here's a piece of code in functions _mesa_dlopen(const char*, int) in
src\mesa\main\dlopen.h (same problem happens with function _mesa_dlsym(void
*, const char *) in the same file).
The original code returns NULL and doesn't load the library if the code is
compiled with Visual Studio.
True but is the library, that is to be opened, there in the first
place ? Last time I've looked nothing seriously bad was happening
(apart from the missing EXT_texture_compression_s3tc and
ANGLE_texture_compression_dxt extensions) when we fail to open the
dxtn library.

Cheers,
Emil
Post by Shervin Sharifi
#if defined(HAVE_DLOPEN)
flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */
return dlopen(libname, flags);
#elif defined(__MINGW32__)
return LoadLibraryA(libname);
#else
return NULL;
#endif
#elif defined(_WIN32)
return LoadLibraryA(libname);
Thanks,
Shervin
Jose Fonseca
2015-04-14 13:10:18 UTC
Permalink
Post by Emil Velikov
Hi Shervin,
Post by Shervin Sharifi
Hi,
I tried to use Mesa (compiled with MSVC) to run OpenGL ES content on
Windows . I ran into a few problems.
I don't know if this is the right way of reporting issues, but thought
people may be interested to know.
Another thing would be to file a bug report, although most people
appreciate patches (send via git send-email) even more :-)
Post by Shervin Sharifi
Here's a piece of code in functions _mesa_dlopen(const char*, int) in
src\mesa\main\dlopen.h (same problem happens with function _mesa_dlsym(void
*, const char *) in the same file).
The original code returns NULL and doesn't load the library if the code is
compiled with Visual Studio.
True but is the library, that is to be opened, there in the first
place ? Last time I've looked nothing seriously bad was happening
(apart from the missing EXT_texture_compression_s3tc and
ANGLE_texture_compression_dxt extensions) when we fail to open the
dxtn library.
Cheers,
Emil
Post by Shervin Sharifi
#if defined(HAVE_DLOPEN)
flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */
return dlopen(libname, flags);
#elif defined(__MINGW32__)
return LoadLibraryA(libname);
#else
return NULL;
#endif
#elif defined(_WIN32)
return LoadLibraryA(libname);
Thanks,
Shervin
Yep, the C-pre-processor logic is wrong.

But as Emil said, unless you actually have a Windows build of the
libtxc_dxtn library it won't make any difference in practice.

Jose

Loading...