I’m trying to cross-compile SDL apps for Windows on Mac OS X using MinGW,
and I’m hitting a problem that I haven’t been able to solve using the
mailing list archives and Google. As I haven’t seen any success (or
failure) reports about MinGW on Mac OS X, I’m not sure whether it’s a
general problem or I’m just doing some little thing wrong.
I followed the instructions in <http://www.libsdl.org/extras/win32/cross/
README.txt> and everything seemed to work fine. I then used the newly
installed cross-compiler to compile SDL 1.2.7, which seems to have worked
as well. I got (among lots of other files, of course) libSDL.a,
libSDL.dll.a, libSDL.la and libSDLmain.a in /usr/local/cross-tools/lib and
SDL.dll in /usr/local/cross-tools/bin (that seems odd - is that the right
place for that file?).
I made some little changes to cross-configure.sh: Added
elif [ -f “$PREFIX/bin/$TARGET-sdl-config” ]; then
SDL_CONFIG="$PREFIX/bin/$TARGET-sdl-config"
export SDL_CONFIG
fi
because that’s where sdl-config was installed for me, and removed
"–build=i386-linux" from the configure command line (I’m not sure why
that was there, because configure seems to guess the build system
(powerpc-apple-darwin7.3.0 in my case) right on its own).
Now I tried compiling the SDL test applications:
SDL-1.2.7/test cwalther$ …/…/…/cross-configure.sh
…(everything seems OK)…
SDL-1.2.7/test cwalther$ …/…/…/cross-make.sh
i386-mingw32msvc-gcc -DPACKAGE_NAME="" -DPACKAGE_TARNAME="" -DPACKAGE_VERSION="" -DPACKAGE_STRING="" -DPACKAGE_BUGREPORT="" -DPACKAGE=“SDL_tests” -DVERSION=“1.2.7” -I. -I. -g -O2 -I/usr/local/cross-tools/include/SDL -Dmain=SDL_main -DHAVE_OPENGL -c testver.c
i386-mingw32msvc-gcc -g -O2 -I/usr/local/cross-tools/include/SDL -Dmain=SDL_main -DHAVE_OPENGL -o testver.exe testver.o -L/usr/local/cross-tools/lib -lmingw32 -lSDLmain -lSDL -mwindows
testver.o(.text+0xa9): In function SDL_main': /Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/test/testver.c:16: undefined reference to
SDL_Init’
testver.o(.text+0xe5):/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/test/testver.c:31: undefined reference to SDL_Linked_Version' testver.o(.text+0xf6):/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/test/testver.c:31: undefined reference to
SDL_Linked_Version’
testver.o(.text+0x109):/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/test/testver.c:31: undefined reference to SDL_Linked_Version' testver.o(.text+0x133):/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/test/testver.c:37: undefined reference to
SDL_Quit’
testver.o(.text+0x13f):/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/test/testver.c:17: undefined reference to SDL_GetError' /usr/local/cross-tools/lib/libSDLmain.a(SDL_win32_main.o.b)(.text+0x2c9): In function
console_main’:
/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/src/main/win32/SDL_win32_main.c:219: undefined reference to SDL_Init' /usr/local/cross-tools/lib/libSDLmain.a(SDL_win32_main.o.b)(.text+0x2d8):/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/src/main/win32/SDL_win32_main.c:256: undefined reference to
SDL_GetError’
/usr/local/cross-tools/lib/libSDLmain.a(SDL_win32_main.o.b)(.text+0x334):/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/src/main/win32/SDL_win32_main.c:224: undefined reference to `SDL_Quit’
make: *** [testver.exe] Error 1
This is the error that I don’t understand. The linker flags look right to
me, and the SDL library seems to contain the symbols that the linker
complains about:
cwalther$ /usr/local/cross-tools/bin/i386-mingw32msvc-nm /usr/local/cross-tools/lib/libSDL.a | grep -E 'SDL_(Init|Linked|Quit|GetError)'
00000190 T _SDL_Init
00000020 T _SDL_InitSubSystem
000002e0 T _SDL_Linked_Version
000002c0 T _SDL_Quit
000001d0 T _SDL_QuitSubSystem
00000660 T _SDL_GetError
000005f0 T _SDL_GetErrorMsg
000003c0 T _SDL_GetErrorMsgUNICODE
U _SDL_Quit
U _SDL_InitSubSystem
U _SDL_QuitSubSystem
U _SDL_GetError
U _SDL_Init
U _SDL_QuitInit
00000020 T _SDL_QuitInit
(I don’t actually know what ‘nm’ does, I read about doing that in a post
on another list about a similar problem. But the output seems to indicate
that the library is OK.)
The first thing I tried was copying SDL.dll (from cross-tools/bin) into
the test directory, as <http://www.libsdl.org/extras/win32/mingw32/
README.txt> says, but that didn’t change anything.
Reordering “-lmingw32 -lSDLmain -lSDL” in the makefile doesn’t help
either. An interesting tidbit is that when I swap -lSDL and -lSDLmain, I
get the same errors as above plus an additional one:
/usr/local/cross-tools/lib/libSDLmain.a(SDL_win32_main.o.b)(.text+0x34b):
/Users/cwalther/Desktop/Incoming/MinGW-Cross/SDL-build/SDL-1.2.7/src/main/
win32/SDL_win32_main.c:244: undefined reference to `SDL_SetModuleHandle’
Another thing: SDL-1.2.7/INSTALL says: “If you are cross-compiling from
Linux to Win32, you should read the file README.Win32” - but I can’t find
such a file, neither in my local copy nor in the CVS. Would that file
contain anything that helps me?
So, that’s where I’m stuck. Any ideas?
-Christian