MinGW cross-compilation on Mac OS X problems

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 toSDL_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 toSDL_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 toSDL_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 functionconsole_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 toSDL_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

maybe you can check whether your makefile include flags created by ‘$(YOURSDLCONFIGPATH)/sdl-config --flags’.> 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 toSDL_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 toSDL_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 toSDL_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 functionconsole_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 toSDL_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


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

========================================================

??? ??? VIP??? ??? http://vip.163.com

??? 25???4??? http://mail.163.com

??? ??? http://popo.163.com

higsn wrote:

maybe you can check whether your makefile include flags created by
’$(YOURSDLCONFIGPATH)/sdl-config --flags’.

cwalther$ /usr/local/cross-tools/bin/i386-mingw32msvc-sdl-config --flags
Usage: sdl-config [–prefix[=DIR]] [–exec-prefix[=DIR]] [–version]
[–cflags] [–libs] [–static-libs]

I suppose you mean ‘sdl-config --cflags’ or ‘sdl-config --libs’? The
output of these two is indeed in the makefile. It is

cwalther$ /usr/local/cross-tools/bin/i386-mingw32msvc-sdl-config --cflags --libs
-I/usr/local/cross-tools/include/SDL -Dmain=SDL_main
-L/usr/local/cross-tools/lib -lmingw32 -lSDLmain -lSDL -mwindows

That doesn’t seem to be the problem.

-Christian

Christian Walther wrote:

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’ve a working mingw32 installed on my powerbook :slight_smile:

So, that’s where I’m stuck. Any ideas?

Try with a prebuilt SDL version, it’s not needed a recompiled one, so
you can exclude that the problem is the SDL build, also try for instance
with a link line like this:

LFLAGS = -lmingw32 -lSDLmain -lSDL -mwindows

etw.exe: $(OBJECTS)
$(CC) -o $@ $(CROSSDIR)/lib/libSDLmain.a $(OBJECTS) $(LFLAGS)

BTW:

My opensource soccer game Eat The Whistle (etw.sourceforge.net) compiles
without warning on my OSX hosted mingw32, you can grab the sources from
the CVS to try your crosscompiler.

Bye,
Gabry

Hello !

Something like this on the libSDL Page
would be really cool.

CU> Christian Walther wrote:

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’ve a working mingw32 installed on my powerbook :slight_smile:

So, that’s where I’m stuck. Any ideas?

Try with a prebuilt SDL version, it’s not needed a recompiled one, so
you can exclude that the problem is the SDL build, also try for instance
with a link line like this:

LFLAGS = -lmingw32 -lSDLmain -lSDL -mwindows

etw.exe: $(OBJECTS)
$(CC) -o $@ $(CROSSDIR)/lib/libSDLmain.a $(OBJECTS) $(LFLAGS)

BTW:

My opensource soccer game Eat The Whistle (etw.sourceforge.net) compiles
without warning on my OSX hosted mingw32, you can grab the sources from
the CVS to try your crosscompiler.

Bye,
Gabry


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello !

Something like this on the libSDL Page
would be really cool.

The other way round would be also cool,
because Mac People can use PC emulators,
there are no PPC emus for PCs.

CU

Actually there is one under development, http://pearpc.sourceforge.net
It is very slow, and cannot be used for something good at the moment but maybe
in the future.

// Alexander BussmanOn Thursday 13 May 2004 12.12, Torsten Giebl wrote:

The other way round would be also cool,
because Mac People can use PC emulators,
there are no PPC emus for PCs.

Hello !

Actually there is one under development, http://pearpc.sourceforge.net
It is very slow, and cannot be used for something good at the moment but
maybe
in the future.

WOAH! Looks pretty good.

CU