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 1378

Summary: Cross compilation with Mingw32 fails
Product: SDL Reporter: Gabriel Jacobo <gabomdq>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: Windows (All)   

Description Gabriel Jacobo 2012-01-18 15:29:43 UTC
I used to be able to run:

./configure LDFLAGS="-static-libgcc" --disable-stdio-redirect --host=i586-mingw32msvc --disable-shared --enable-static --prefix=something
make;make install

From my Ubuntu 11.10 and get a working win32 library to link with my project. However, lately I ran into a few problems:

I have to set CFLAGS="-DHAVE_LIBC=1 -DSDL_HAPTIC_DUMMY=1 -DSDL_JOYSTICK_WINMM=1"

And I have to edit SDL_config_windows.h to remove the following two lines:

#define SDL_AUDIO_DRIVER_DSOUND	1
#define SDL_AUDIO_DRIVER_XAUDIO2 1


The HAVE_LIBC bit is simple enough, if it's not defined all the SDL_sqrt, SDL_cos, etc end up getting reported as missing symbols during link time.
SDL_HAPTIC_DUMMY=1 is required because the config script enables SDL_haptic.c but it doesnt seem to provide any backend for it (otherwise you get missing symbols errors)
SDL_JOYSTICK_WINMM=1 is required for a similar reason. Even if I ran configure with --disable-joystick, SDL_joystick.c is still included in the compilation with no backend (again, missing symbols at link). The configure script seems to detect properly that WINMM Joystick support is required and it includes the WINMM backend for it, but for some reason SDL_JOYSTICK_WINMM needs to be forcefully defined.

The manual edits to SDL_config_windows.h are required because even though the configure scripts detects (correctly?) support for XAudio and DSound, both SDL_xaudio2.c and SDL_directsound.c are not included in the Makefile (they are mentioned in the Visual Studio project files only, which have no role in this setup).
Comment 1 Sam Lantinga 2012-01-18 22:57:21 UTC
You're right, that's confusing.

Fixed, thanks!
http://hg.libsdl.org/SDL/rev/d169541f5049
Comment 2 Gabriel Jacobo 2012-01-22 16:48:24 UTC
I'm posting here as I think this is related, though the problem is for Ubuntu this time.
After running ./configure and make, I get (sorry for the spanish localization)


/bin/bash build-scripts/updaterev.sh
/bin/bash ./libtool --mode=compile gcc -g -O3 -DUSING_GENERATED_CONFIG_H -I./include  -mmmx -m3dnow -msse -msse2 -fvisibility=hidden  -D_REENTRANT       -D_REENTRANT -DHAVE_LINUX_VERSION_H -Wall -MMD -MT build/SDL.lo -c src/SDL.c -o build/SDL.lo
libtool: compile:  gcc -g -O3 -DUSING_GENERATED_CONFIG_H -I./include -mmmx -m3dnow -msse -msse2 -fvisibility=hidden -D_REENTRANT -D_REENTRANT -DHAVE_LINUX_VERSION_H -Wall -MMD -MT build/SDL.lo -c src/SDL.c  -fPIC -DPIC -o build/.libs/SDL.o
In file included from ./include/SDL_config.h:44:0,
                 from src/SDL.c:21:
./include/SDL_config_minimal.h:37:22: error: tipos en conflicto para ‘size_t’
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include/stddef.h:212:23: nota: la declaración previa de ‘size_t’ estaba aquí
In file included from src/SDL.c:21:0:
./include/SDL_config.h:48:2: error: #error Wrong SDL_config.h, check your include path?
In file included from /usr/include/stdlib.h:320:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include/mm_malloc.h:27,
                 from /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include/xmmintrin.h:39,
                 from ./include/SDL_cpuinfo.h:59,
                 from ./include/SDL.h:78,
                 from src/SDL.c:25:
/usr/include/x86_64-linux-gnu/sys/types.h:198:1: error: tipos en conflicto para ‘int64_t’
./include/SDL_config_minimal.h:44:26: nota: la declaración previa de ‘int64_t’ estaba aquí
src/SDL.c:46:15: aviso: se define ‘ticks_started’ pero no se usa [-Wunused-variable]
Comment 3 Gabriel Jacobo 2012-01-23 05:16:46 UTC
With a clean checkout of the code this works, so the problem is local. Closing. Apologies!