Installing the Cross-Compiler

I suggest you create and chown /usr/local/cross-tools to the user who will do the cross-compiling before installing, so you don't need to compile as root. The SDL-Project maintains an excellent script to download and build the mingw32 cross-compiler. Follow the Instructions.

Cross-Compiling SDL

Put the scripts and (mentioned at the end of the instructions above) somewhere into your $PATH, and make them executable. Edit and add --prefix="$PREFIX/$TARGET" to the configure command. Now download the latest .tar.gz of SDL, and maybe some additional libraries (my mass project needs SDL_net and freetype2), extract them, and run for each && && install
(Note 2004-10-12: If compiling fails, try --disable-nasm)
This will produce a .dll /usr/local/cross-tools/i386-mingw32msvc/lib/ which will work, but is not stripped (1.7 MB huge in case of SDL.dll). Get the stripped version from the binary pages of the corresponding library (usually a .zip), it seems to be a bit tricky to strip them right yourself.

The same steps should now work for your SDL project (perhaps you don't want to install it, though), and you will either get a binary with .exe extension or without, it seems to change every now and then... make sure the type is right:

$ file mass.exe 
mass.exe: MS Windows PE Intel 80386 GUI executable not relocatable
This one you'll have to strip yourself. For consistency you might want my, but this works too:
$ ls -sSh mass.exe
468K mass.exe
$ /usr/local/cross-tools/bin/i386-mingw32msvc-strip mass.exe
$ ls -sSh mass.exe
 68K mass.exe
That's it, try it! And if you are one of the sort who can't be bothered starting Windows, tell someone else to try it. He'll have to copy SDL.dll (and others, for mass eg SDL_net.dll) into the same directory.

If you feel like being nice, zip them up into a single file.

$ unix2dos *.txt
$ zip mass.exe SDL.dll SDL_net.dll README.txt COPYING.txt 
adding: mass.exe (deflated 49%)
adding: SDL.dll (deflated 58%)
adding: SDL_net.dll (deflated 82%)
adding: README.txt (deflated 46%)
adding: COPYING.txt (deflated 62%)
This should be automated somehow (a script), and I do not yet know how I would do it with binary files (bitmaps...) that have to be distributed. Something with "make install" might be a solution, or better seperate them in a data/ directory and add this to the .zip.

You can remove your build directories (the cross-compiler, and the libraries too if you want), which was alltogether 283M huge for me.

Links to similar texts: here, here (clanlib), here (wxwindows wiki)
TODO: move this text into a wiki so anyone can edit it. If YOU want to do this, please go ahead, and mail me the link so I can wipe out this page.

Martin Renold (maillink)
Back to my homepage (mostly german)