Cross-compiling Windows version from Linux

From Armagetron
Revision as of 11:15, 10 June 2006 by Wrtlprnft (talk | contribs) (fixed code sections for easier copy and paste)

Just collecting cross-compilation notes.

Setting up the cross compiler under linux

Check your distribution for mingw packages. If it has it, install them. If not, try this:

http://www.libsdl.org/extras/win32/cross/

Export some environment variable:

export CC=i586-mingw32msvc-gcc
export CXX=i586-mingw32msvc-c++
export LD=i586-mingw32msvc-ld
export AR=i586-mingw32msvc-ar
export AS=i586-mingw32msvc-as
export NM=i586-mingw32msvc-nm
export STRIP=i586-mingw32msvc-strip
export RANLIB=i586-mingw32msvc-ranlib
export DLLTOOL=i586-mingw32msvc-dlltool
export OBJDUMP=i586-mingw32msvc-objdump
export RESCOMP=i586-mingw32msvc-windres

You might want those in a script.

Libraries

You'll need to use the same configure command to configure and install the libraries. Get libSDL and libxml2 and do this:

./configure --host=i586-mingw32msvc --prefix=/usr/i586-mingw32msvc

Prefix is the location of your cross-compiler, it should have "bin", "lib", and "include" in it.

To get libxml2 to cross-compile, use this as your configure command:

./configure --host=i586-mingw32msvc --prefix=/usr/i586-mingw32msvc --with-python=no

Armagetron Advanced

You need to set some influential environment variables to make it configure.

XML2_CONFIG=/path/to/cross-compiled/xml2-config SDL_CONFIG=/path/to/cross-compiled/sdl-config

Example:

XML2_CONFIG=/usr/i586-mingw32msvc/bin/xml2-config SDL_CONFIG=/usr/i586-mingw32msvc/bin/sdl-config ../../armagetronadnew/configure --host=i586-mingw32msvc --prefix=/usr/i586-mingw32msvc --disable-sound

Currently it's failing for me with this line:

 checking for glVertex3f in -lopengl32... no
 OpenGL not found. Maybe it needs X11 to compile? Checking that...

Dedicated Server

Same as above, only try this configure line instead:


XML2_CONFIG=/usr/i586-mingw32msvc/bin/xml2-config SDL_CONFIG=/usr/i586-mingw32msvc/bin/sdl-config CFLAGS="-I/usr/i586-mingw32msvc/include -DNO_SOCKLEN_T" CXXFLAGS="-I/usr/i586-mingw32msvc/include" ../../armagetronadnew/configure --host=i586-mingw32msvc --prefix=/usr/i586-mingw32msvc --disable-sound --disable-glout --disable-binreloc

This will configure, but it fails in nSocket.cpp with the version of MingW that I have on my Kubuntu system. I'd appreciate if someone can try it with a different version, maybe it's just the version I've got.