We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3693

Summary: Cross Compiling OS X to Windows - SDL_xinput compilation errors
Product: SDL Reporter: Robert D Blanchet Jr <xgalaxy>
Component: *don't know*Assignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: 2.0.5   
Hardware: x86_64   
OS: Other   

Description Robert D Blanchet Jr 2017-07-05 18:44:04 UTC
Hello. I'm using SDL-2.0.5 with CMake and Mingw-w64 (version 5.0.2) on OS X to cross compile to Windows. I get compilation errors in SDL_xinput.

Here is the CMake output:

The C compiler identification is GNU 7.1.0
Check for working C compiler: /usr/local/bin/x86_64-w64-mingw32-gcc
Check for working C compiler: /usr/local/bin/x86_64-w64-mingw32-gcc -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE) 
0.4.1 :: 4 :: 1 :: 4 :: 2.0
Performing Test HAVE_GCC_WALL
Performing Test HAVE_GCC_WALL - Success
Performing Test HAVE_GCC_WDECLARATION_AFTER_STATEMENT
Performing Test HAVE_GCC_WDECLARATION_AFTER_STATEMENT - Success
Performing Test HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT
Performing Test HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT - Success
Performing Test HAVE_GCC_ATOMICS
Performing Test HAVE_GCC_ATOMICS - Success
Performing Test HAVE_GCC_PREFERRED_STACK_BOUNDARY
Performing Test HAVE_GCC_PREFERRED_STACK_BOUNDARY - Failed
Performing Test HAVE_GCC_FVISIBILITY
Performing Test HAVE_GCC_FVISIBILITY - Success
Performing Test HAVE_GCC_WSHADOW
Performing Test HAVE_GCC_WSHADOW - Success
Performing Test HAVE_NO_UNDEFINED
Performing Test HAVE_NO_UNDEFINED - Success
Performing Test HAVE_MMX
Performing Test HAVE_MMX - Success
Performing Test HAVE_3DNOW
Performing Test HAVE_3DNOW - Success
Performing Test HAVE_SSE
Performing Test HAVE_SSE - Success
Performing Test HAVE_SSE2
Performing Test HAVE_SSE2 - Success
Performing Test HAVE_SSE3
Performing Test HAVE_SSE3 - Success
Performing Test HAVE_ALTIVEC_H_HDR
Performing Test HAVE_ALTIVEC_H_HDR - Failed
Performing Test HAVE_ALTIVEC
Performing Test HAVE_ALTIVEC - Failed
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdio.h
Looking for stdio.h - found
Looking for stdlib.h
Looking for stdlib.h - found
Looking for stddef.h
Looking for stddef.h - found
Looking for stdarg.h
Looking for stdarg.h - found
Looking for malloc.h
Looking for malloc.h - found
Looking for memory.h
Looking for memory.h - found
Looking for string.h
Looking for string.h - found
Looking for strings.h
Looking for strings.h - found
Looking for inttypes.h
Looking for inttypes.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for ctype.h
Looking for ctype.h - found
Looking for math.h
Looking for math.h - found
Looking for iconv.h
Looking for iconv.h - not found
Looking for signal.h
Looking for signal.h - found
Looking for 8 include files dlfcn.h, ..., float.h
Looking for 8 include files dlfcn.h, ..., float.h - not found
Check size of size_t
Check size of size_t - done
Looking for M_PI
Looking for M_PI - found
Performing Test HAVE_MPROTECT
Performing Test HAVE_MPROTECT - Failed
Looking for strtod
Looking for strtod - found
Looking for malloc
Looking for malloc - found
Looking for calloc
Looking for calloc - found
Looking for realloc
Looking for realloc - found
Looking for free
Looking for free - found
Looking for getenv
Looking for getenv - found
Looking for setenv
Looking for setenv - not found
Looking for putenv
Looking for putenv - found
Looking for unsetenv
Looking for unsetenv - not found
Looking for qsort
Looking for qsort - found
Looking for abs
Looking for abs - found
Looking for bcopy
Looking for bcopy - not found
Looking for memset
Looking for memset - found
Looking for memcpy
Looking for memcpy - found
Looking for memmove
Looking for memmove - found
Looking for memcmp
Looking for memcmp - found
Looking for strlen
Looking for strlen - found
Looking for strlcpy
Looking for strlcpy - not found
Looking for strlcat
Looking for strlcat - not found
Looking for strdup
Looking for strdup - found
Looking for _strrev
Looking for _strrev - found
Looking for _strupr
Looking for _strupr - found
Looking for _strlwr
Looking for _strlwr - found
Looking for strchr
Looking for strchr - found
Looking for strrchr
Looking for strrchr - found
Looking for strstr
Looking for strstr - found
Looking for itoa
Looking for itoa - found
Looking for _ltoa
Looking for _ltoa - found
Looking for _uitoa
Looking for _uitoa - not found
Looking for _ultoa
Looking for _ultoa - found
Looking for strtol
Looking for strtol - found
Looking for strtoul
Looking for strtoul - found
Looking for _i64toa
Looking for _i64toa - found
Looking for _ui64toa
Looking for _ui64toa - found
Looking for strtoll
Looking for strtoll - found
Looking for strtoull
Looking for strtoull - found
Looking for atoi
Looking for atoi - found
Looking for atof
Looking for atof - found
Looking for strcmp
Looking for strcmp - found
Looking for strncmp
Looking for strncmp - found
Looking for _stricmp
Looking for _stricmp - found
Looking for strcasecmp
Looking for strcasecmp - found
Looking for _strnicmp
Looking for _strnicmp - found
Looking for strncasecmp
Looking for strncasecmp - found
Looking for vsscanf
Looking for vsscanf - found
Looking for vsnprintf
Looking for vsnprintf - found
Looking for fseeko
Looking for fseeko - found
Looking for fseeko64
Looking for fseeko64 - found
Looking for sigaction
Looking for sigaction - not found
Looking for setjmp
Looking for setjmp - found
Looking for nanosleep
Looking for nanosleep - not found
Looking for sysconf
Looking for sysconf - not found
Looking for sysctlbyname
Looking for sysctlbyname - not found
Looking for getauxval
Looking for getauxval - not found
Looking for pow in m
Looking for pow in m - found
Looking for atan
Looking for atan - found
Looking for atan2
Looking for atan2 - found
Looking for ceil
Looking for ceil - found
Looking for copysign
Looking for copysign - found
Looking for cos
Looking for cos - found
Looking for cosf
Looking for cosf - found
Looking for fabs
Looking for fabs - found
Looking for floor
Looking for floor - found
Looking for log
Looking for log - found
Looking for pow
Looking for pow - found
Looking for scalbn
Looking for scalbn - found
Looking for sin
Looking for sin - found
Looking for sinf
Looking for sinf - found
Looking for sqrt
Looking for sqrt - found
Looking for sqrtf
Looking for sqrtf - found
Looking for tan
Looking for tan - found
Looking for tanf
Looking for tanf - found
Looking for acos
Looking for acos - found
Looking for asin
Looking for asin - found
Looking for iconv_open in iconv
Looking for iconv_open in iconv - not found
Looking for alloca.h
Looking for alloca.h - not found
Looking for alloca
Looking for alloca - not found
Performing Test HAVE_SA_SIGACTION
Performing Test HAVE_SA_SIGACTION - Failed
Performing Test HAVE_WIN32_CC
Performing Test HAVE_WIN32_CC - Success
Performing Test HAVE_XINPUT_H
Performing Test HAVE_XINPUT_H - Success
Looking for d3d9.h
Looking for d3d9.h - found
Looking for d3d11_1.h
Looking for d3d11_1.h - found
Looking for ddraw.h
Looking for ddraw.h - found
Looking for dsound.h
Looking for dsound.h - found
Looking for dinput.h
Looking for dinput.h - found
Looking for xaudio2.h
Looking for xaudio2.h - not found
Looking for audioclient.h
Looking for audioclient.h - found
Looking for dxgi.h
Looking for dxgi.h - found

SDL2 was configured with the following options:

Platform: Windows
64-bit:   TRUE
Compiler: /usr/local/bin/x86_64-w64-mingw32-gcc




Here is the compilation spew:

In file included from /Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c:24:0:
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.h:142:5: error: unknown type name ‘XINPUT_STATE_EX’; did you mean ‘XINPUT_STATE’?
     XINPUT_STATE_EX* pState     /* [out] Receives the current state */
     ^~~~~~~~~~~~~~~
     XINPUT_STATE
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.h:168:8: error: unknown type name ‘XInputGetState_t’
 extern XInputGetState_t SDL_XInputGetState;
        ^~~~~~~~~~~~~~~~
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c:29:1: error: unknown type name ‘XInputGetState_t’; did you mean ‘XInputSetState_t’?
 XInputGetState_t SDL_XInputGetState = NULL;
 ^~~~~~~~~~~~~~~~
 XInputSetState_t
In file included from /Volumes/Projects HD/Code/vendor/sdl2/include/SDL_platform.h:166:0,
                 from /Volumes/Projects HD/Code/vendor/sdl2-win/sdl2-build/include/SDL_config.h:32,
                 from /Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/../../SDL_internal.h:48,
                 from /Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c:21:
/Volumes/Projects HD/Code/vendor/sdl2/include/begin_code.h:153:14: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
 #define NULL ((void *)0)
              ^
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c:29:39: note: in expansion of macro ‘NULL’
 XInputGetState_t SDL_XInputGetState = NULL;
                                       ^~~~
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c: In function ‘WIN_LoadXInputDLL’:
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c:107:27: error: ‘XInputGetState_t’ undeclared (first use in this function); did you mean ‘XInputSetState_t’?
     SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, (LPCSTR)100);
                           ^~~~~~~~~~~~~~~~
                           XInputSetState_t
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c:107:27: note: each undeclared identifier is reported only once for each function it appears in
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c:107:44: error: expected ‘;’ before ‘GetProcAddress’
     SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, (LPCSTR)100);
                                            ^~~~~~~~~~~~~~
/Volumes/Projects HD/Code/vendor/sdl2/src/core/windows/SDL_xinput.c:109:48: error: expected ‘;’ before ‘GetProcAddress’
         SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetState");
                                                ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/SDL2-static.dir/src/core/windows/SDL_xinput.c.obj] Error 1
make[1]: *** [CMakeFiles/SDL2-static.dir/all] Error 2
make: *** [all] Error 2
Comment 1 Robert D Blanchet Jr 2017-07-05 18:56:48 UTC
Commenting out the section which defines HAS_XINPUT_GAMEPAD_EX and HAS_XINPUT_STATE_EX if MINGW32 is defined and GCC is a particular version - the code will compile and the rest of the SDL2 library successfully builds.

I doubt this change is the particular fix that is required. But it has unblocked me until an appropriate fix is implemented.
Comment 2 Ozkan Sezer 2017-07-06 08:27:54 UTC
See bug #3609
Comment 3 Sam Lantinga 2017-07-11 01:35:24 UTC
This should be fixed in the latest snapshot:
http://www.libsdl.org/tmp/SDL-2.0.zip

Thanks!