Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Include file sal.h not part of MinGW

Credits go to beoran and SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
Include file sal.h not part of MinGW
Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Latest Git fails to build because it is missing sal.h. I'm on Vista with MinGW 4.8.1.

Allegro 5.1.X Git said:

whapxi.c#SelectExpand
55 56/* The official DirectX xinput.h uses SAL annotations. 57 * Need the sal.h header to get rid of them. On some other platforms 58 * such as MinGW on Linux this header is lacking because it is not needed there. 59 * So, simply try to include sal.h IF we have it , and if not, hope 60 * for the best. 61 * This does no harm on msys2 either, they have a sal.h header. 62 */ 63#ifdef ALLEGRO_HAVE_SAL_H 64#endif 65 66#include <sal.h> 67#include <xinput.h>

Shouldn't the #include <sal.h> be inside the #ifdef ALLEGRO_HAVE_SAL_H? Because sal.h doestn' exist in MinGW 4.8.1. Is ALLEGRO_HAVE_SAL_H defined anywhere for MinGW?

Edit
I fixed that, so it only checks for sal.h if ALLEGRO_HAVE_SAL_H is defined, but now it can't find xinput.h.

beoran
Member #12,636
March 2011

Yes, I programmed that and I had some problems with those header files. If you can't upgrade to msys2, then you will probably need to install the DirectX headers, including xinput.h somewhere where cmake can find them. These will probably need to be the "cleaned up" DirectX headers as well, but I forget where to find those... :p

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

All due respect to the haptic addon, but its not really core functionality. I am fairly certain I will never need haptics (even though they would be cool) and so I should be able to build Allegro 5 without haptic support if need be.

Also, do I really really need to use the giant ass DirectX SDK? I've been using the dx9mgw.zip for directx support for ages and now I can't compile Allegro with it anymore? That's kind of rough.

How do I work around this for now so I can build Allegro and use it again? Is this in 5.1.10 as well?

beoran
Member #12,636
March 2011

It's not just haptics, but also the driver for xinput joypads, such as the xbox controller. Many people have that so you probably do want xinput support if you can get it. And yes, it's in 5.1.10 as well.

And haptics are not an addon but part of the core since they need intimate knowledge of the joystick's internals, but I digress...

I'm reminded of https://www.allegro.cc/forums/thread/615007. The build system does detect if xinput.h is present or not, but sometimes this seems to go awry. Could you check if you already have an xinput.h somewhere? Otherwise this could be a subtle problem with the build system.

Alternatively disable ALLEGRO_CFG_XINPUT to not compile the xinput driver. Edit: Or as I said, why not upgrade to msys2? AFAICS msys2 works also on vista and it's much easier to install Allegro and it's dependencies with msys2.

The problem with dx9mgw.zip is that needs to be updated to include XInput.h, which is a part of directx9 indeed, but was probably omitted from the zip file since Allegro didn't need it way back when. Can anyone do this for us, please? For the
toime being you can get a copy of the file here: https://xp-dev.com/sc/42699/44/%2FSource%2FEngine%2FDirectX9%28August%29%2FInclude%2FXInput.h

Edit: Anyway, I hope we can find out what causes this problem. I appreciate your help because I lost my Windows dev environment a few months ago. The laptop fell drown and broke. :'(

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Cmake is detecting xinput in

XINPUT_INCLUDE_DIR
C:/Program Files/Microsoft SDKs/Windows/v7.1/Include

XINPUT_LIBRARY
C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib/Xinput.lib

So it is mistakenly finding .lib files for MSVC instead of MinGW, as MinGW doesn't come with xinput.h.

SiegeLord said:

If that yields nothing, the thing you want to disable is ALLEGRO_CFG_XINPUT.

I don't know how to disable ALLEGRO_CFG_XINPUT - it's not listed in cmake-gui. What would I pass on the command line?

Beoran said:

That's not gonna help because I won't have a version of directx with the symbols for xinput to link against.

And I don't really want to 'upgrade' to MSYS2. I'm perfectly happy with my degenerate little MinGW installation. It has served me well so far.

SiegeLord
Member #7,827
October 2006
avatar

Looks like I made the FindDirectX.cmake a bit too smart about finding the headers. I think the proper solution is to add a compile test, which would catch this kind of stuff. I'll get around it this soonish.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

My immediate workaround to get it to compile was to set XINPUT_INCLUDE_DIR and XINPUT_LIBRARY to empty strings in cmake-gui so cmake couldn't find xinput. It then disabled it and Allegro built fine after that.

Here's a patch to fix the issue with ALLEGRO_HAVE_SAL_H in whapxi.c :
https://www.allegro.cc/files/attachment/609429

#SelectExpand
1 src/win/whapxi.c | 2 +- 2 1 file changed, 1 insertion(+), 1 deletion(-) 3 4diff --git a/src/win/whapxi.c b/src/win/whapxi.c 5index 8379b98..9bbe8eb 100644 6--- a/src/win/whapxi.c 7+++ b/src/win/whapxi.c 8@@ -61,9 +61,9 @@ 9 * This does no harm on msys2 either, they have a sal.h header. 10 */ 11 #ifdef ALLEGRO_HAVE_SAL_H 12+ #include <sal.h> 13 #endif 14 15-#include <sal.h> 16 #include <xinput.h> 17 18 #include "allegro5/internal/aintern_wjoyxi.h"

beoran
Member #12,636
March 2011

Glad to hear you found a workaround. I also agree that a compile test would be a great idea. And that patch should be applied, I feel a bit embarrassed I missed that silly mistake with sal.h

But I feel that xinput should also work on mingw if we can update the diectx9 zip file with the xinput header and library. The Allegro Xinput driver definitely improves the experience of xinput joypads.

Edit: Siegelord, if you are going to make a 5.1.11 release then please include this patch as well? Thanks!

SiegeLord
Member #7,827
October 2006
avatar

I applied this patch, but I still want to fix the path searching properly (and probably add a compile test).

EDIT: I adjusted how CMake looks for headers in http://sourceforge.net/p/alleg/allegro/ci/961db9e540bb4f9b9e74d7af53dd215d5ed6d3e4/ so it shouldn't find MSVC headers while you're on MinGW.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Go to: