Difference between revisions of "Cross-compiling Windows version from Linux"

From Armagetron
 
(10 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[http://people.msoe.edu/~millerni/forums.php?show=topic&id=96&forum=13 buy diazepam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=148&forum=13 tramadol online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=156&forum=13 cheap wellbutrin] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=107&forum=13 free jazz ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a00 rivotril online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=119&forum=13 mtv ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=110&forum=13 lipitor online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=89&forum=13 celexa online] [http://wc1.worldcrossing.com/WebX/.1de609e0 cheap ativan] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=123&forum=13 free nokia ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f9 order norco] [http://wc1.worldcrossing.com/WebX/.1de60a18 motorola ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2c but ultram] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=150&forum=13 ultram online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=124&forum=13 norco] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=116&forum=13 mono ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0e celexa online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=97&forum=13 buy didrex] [http://wc1.worldcrossing.com/WebX/.1de609fa free online pharmacy] [http://wc1.worldcrossing.com/WebX/.1de60a24 propecia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=128&forum=13 phentermine online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=153&forum=13 buy viagra] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=154&forum=13 vicodin online] [http://wc1.worldcrossing.com/WebX/.1de60a27 cheap sildenafil] [http://wc1.worldcrossing.com/WebX/.1de60a1f lisinopril online] [http://wc1.worldcrossing.com/WebX/.1de60a26 sharp ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a16 levitra] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=103&forum=13 free funny ringtones] [http://wc1.worldcrossing.com/WebX/.1de609ee but hydrocodone] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=151&forum=13 valium] [http://wc1.worldcrossing.com/WebX/.1de609e5 cool ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e4 clonazepam online] [http://wc1.worldcrossing.com/WebX/.1de609e6 buy cyclobenzaprine] [http://wc1.worldcrossing.com/WebX/.1de60a35 free verizon ringtones] [http://wc1.worldcrossing.com/WebX/.1de609ec buy hgh] [http://wc1.worldcrossing.com/WebX/.1de609df cheap ambien] [http://wc1.worldcrossing.com/WebX/.1de60a03 free sony ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0f cheap cialis] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=91&forum=13 cingular ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=90&forum=13 cheap cialis] [http://wc1.worldcrossing.com/WebX/.1de60a33 prozac online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=133&forum=13 qwest ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a10 cheap didrex] [http://wc1.worldcrossing.com/WebX/.1de609fd punk ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a14 free jazz ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=102&forum=13 free free ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2b cheap ultracet] [http://wc1.worldcrossing.com/WebX/.1de60a1e order flexeril] [http://wc1.worldcrossing.com/WebX/.1de609f8 free nokia ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=87&forum=13 cheap ativan] [http://wc1.worldcrossing.com/WebX/.1de60a09 cheap viagra] [http://wc1.worldcrossing.com/WebX/.1de609f3 midi ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=142&forum=13 sony ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=135&forum=13 real ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=82&forum=13 cheap adipex] [http://wc1.worldcrossing.com/WebX/.1de609eb free funny ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=132&forum=13 free punk ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=146&forum=13 cheap tenuate] [http://wc1.worldcrossing.com/WebX/.1de609f2 online meridia] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=108&forum=13 free kyocera ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a05 free sprint ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=114&forum=13 online meridia] [http://wc1.worldcrossing.com/WebX/.1de60a06 cheap tenuate] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=92&forum=13 cheap clomid] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=86&forum=13 order ambien] [http://wc1.worldcrossing.com/WebX/.1de60a04 free sonyericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e3 cheap clomid] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=120&forum=13 music ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=99&forum=13 free ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=109&forum=13 levitra online] [http://wc1.worldcrossing.com/WebX/.1de60a0d free wwe ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a15 kyocera ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a20 cheap nexium] [http://wc1.worldcrossing.com/WebX/.1de60a19 free mp3 ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=104&forum=13 cheap hgh] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=158&forum=13 xanax online] [http://wc1.worldcrossing.com/WebX/.1de60a01 sagem ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a30 xenical online] [http://wc1.worldcrossing.com/WebX/.1de609de but alprazolam] [http://wc1.worldcrossing.com/WebX/.1de60a1b music ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a31 buy zanaflex] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=152&forum=13 verizon ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f7 free nextel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=147&forum=13 tracfone ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a11 diethylpropion online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=83&forum=13 cheap albuterol] [http://wc1.worldcrossing.com/WebX/.1de60a29 buy tramadol] [http://wc1.worldcrossing.com/WebX/.1de60a25 samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=118&forum=13 mp3 ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=157&forum=13 free wwe ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a28 cheap soma] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=139&forum=13 free sharp ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=111&forum=13 cheap lisinopril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=126&forum=13 paxil online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=117&forum=13 motorola ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=138&forum=13 samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=155&forum=13 vigrx] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=140&forum=13 sildenafil online] [http://wc1.worldcrossing.com/WebX/.1de60a21 buy paxil] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=160&forum=13 zanaflex online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=136&forum=13 cheap rivotril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=98&forum=13 diethylpropion online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=145&forum=13 sprint ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=129&forum=13 polyphonic ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=137&forum=13 free sagem ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=121&forum=13 cheap nexium] [http://wc1.worldcrossing.com/WebX/.1de60a1d cingular ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=95&forum=13 cheap cyclobenzaprine] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=127&forum=13 cheap pharmacy online] [http://wc1.worldcrossing.com/WebX/.1de609dd alltel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=144&forum=13 free sonyericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a34 free sony ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e7 diazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a0a online vicodin] [http://wc1.worldcrossing.com/WebX/.1de60a17 buy lipitor] [http://wc1.worldcrossing.com/WebX/.1de60a0b vigrx online] [http://wc1.worldcrossing.com/WebX/.1de60a1a free mtv ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=141&forum=13 cheap soma] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=112&forum=13 lorazepam online] [http://wc1.worldcrossing.com/WebX/.1de609ff real ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=162&forum=13 cheap zyban] [http://wc1.worldcrossing.com/WebX/.1de609dc albuterol online] [http://wc1.worldcrossing.com/WebX/.1de60a12 free ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f0 cheap lorazepam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=161&forum=13 but zoloft] [http://wc1.worldcrossing.com/WebX/.1de609db cheap adipex] [http://wc1.worldcrossing.com/WebX/.1de60a0c buy wellbutrin] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=84&forum=13 free alltel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=94&forum=13 free cool ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=122&forum=13 free nextel ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a32 zoloft online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=93&forum=13 clonazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a2d valium online] [http://wc1.worldcrossing.com/WebX/.1de60a13 order fioricet] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=115&forum=13 free midi ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2e cheap xanax] [http://wc1.worldcrossing.com/WebX/.1de60a23 polyphonic ringtones] [http://wc1.worldcrossing.com/WebX/.1de609ed hoodia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=113&forum=13 but lortab] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=85&forum=13 alprazolam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=106&forum=13 hydrocodone online] [http://wc1.worldcrossing.com/WebX/.1de609f1 lortab online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=149&forum=13 cheap ultracet] [http://wc1.worldcrossing.com/WebX/.1de609ea free ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f4 mono ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=88&forum=13 cheap carisoprodol] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=143&forum=13 sony ringtones] [http://wc1.worldcrossing.com/WebX/.1de609fb ortho online] [http://wc1.worldcrossing.com/WebX/.1de60a07 tracfone ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a22 but phentermine] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=125&forum=13 cheap ortho] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=159&forum=13 cheap xenical] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=131&forum=13 prozac online] [http://wc1.worldcrossing.com/WebX/.1de609e1 cheap carisoprodol] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=130&forum=13 propecia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=101&forum=13 but flexeril] [http://wc1.worldcrossing.com/WebX/.1de609fe qwest ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=100&forum=13 buy fioricet] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=105&forum=13 cheap hoodia] [http://wc1.worldcrossing.com/WebX/.1de60a36 cheap zyban] Just collecting cross-compilation notes.
+
Just collecting cross-compilation notes.
 +
 
 +
=Autotools=
  
 
== Setting up the cross compiler under linux ==
 
== Setting up the cross compiler under linux ==
Line 10: Line 12:
  
 
  export CC=i586-mingw32msvc-gcc
 
  export CC=i586-mingw32msvc-gcc
  export CXX=i586-mingw32msvc-c
+
  export CXX=i586-mingw32msvc-c++
  export  
+
  export LD=i586-mingw32msvc-ld
1000
 
LD=i586-mingw32msvc-ld
 
 
  export AR=i586-mingw32msvc-ar
 
  export AR=i586-mingw32msvc-ar
 
  export AS=i586-mingw32msvc-as
 
  export AS=i586-mingw32msvc-as
Line 61: Line 61:
  
 
This will configure and build the dedicated server with a recent trunk checkout.  The dedicated server that's built this way has a few issues to work out, but it'll run in Win98 and Wine, the difference being that in Wine you can't connect a client to it.
 
This will configure and build the dedicated server with a recent trunk checkout.  The dedicated server that's built this way has a few issues to work out, but it'll run in Win98 and Wine, the difference being that in Wine you can't connect a client to it.
 +
 +
 +
=CMake=
 +
It is almost possible to cross-build a dedicated server on this branch with linux as build platform and windows as host, so I'm documenting this here
 +
==Dependencies==
 +
Many dependencies had cross-building packages in archlinux's user contributed repository, so I'm only documenting the ones I had trouble with.
 +
===protobuf===
 +
The build process of protobuf includes some .proto compiling with the protoc utility. Since you're going to build protobuf for windows on a linux box, you won't be able to use the protoc you'll build, so you need to have another protoc built for linux with the """same version""" as what you are building.
 +
 +
Once you have built it(or if it is in your system), you need to tell protobuf's configure script where prtoc is:
 +
./configure --host=i486-mingw32 --with=protoc=/path/to/protobuf-x.x.x/src/protoc
 +
 +
One tiny bug will however cause protobuf 2.3.0 not to compile for windows on GCC. It is being fixed for protobuf 2.3.1[http://code.google.com/p/protobuf/issues/detail?id=155]. You can fix it by editing <code>src/google/protobuf/compiler/subprocess.h</code> at line <code>79</code>: Change
 +
static string Subprocess::Win32ErrorMessage(DWORD error_code);
 +
to
 +
static string Win32ErrorMessage(DWORD error_code);
 +
 +
===FTGL===
 +
FTGL's configure script has a bugger: It will look for libGL even though you're compiling for windows which uses libopengl32. Just go ahead and apply this patch of mine to <code>m4/gl.m4</code>
 +
--- /home/epsy/SOURCES/ftgl/src/ftgl-2.1.3~rc5/m4/gl.m4 2008-05-05 16:48:57.000000000 +0200
 +
+++ m4/gl.m4 2010-02-22 00:38:09.000000000 +0100
 +
@@ -54,19 +54,23 @@
 +
 
 +
  AC_MSG_CHECKING([for GL library])
 +
  if test "x$with_gl_lib" != "x" ; then
 +
-    if test -d "$with_gl_lib" ; then
 +
+    if test -d "$with_gl_lib" -a "x$host_os" != "xmingw32" ; then
 +
          LIBS="-L$with_gl_lib -lGL"
 +
+    elif test -d "$with_gl_lib"; then
 +
+        LIBS="-L$with_gl_lib -lopengl32"
 +
      else
 +
          LIBS="$with_gl_lib"
 +
      fi
 +
-else
 +
+elif test "x$host_os" != "xmingw32"; then
 +
      LIBS="-lGL"
 +
+else
 +
+    LIBS="-lopengl32"
 +
  fi
 +
-AC_LINK_IFELSE([AC_LANG_CALL([],[glBegin])],[HAVE_GL=yes], [HAVE_GL=no])
 +
+AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/gl.h>],[glBegin(0)])],[HAVE_GL=yes], [HAVE_GL=no])
 +
  if test "x$HAVE_GL" = xno ; then
 +
      if test "x$GL_X_LIBS" != x ; then
 +
          LIBS="-lGL $GL_X_LIBS"
 +
-        AC_LINK_IFELSE([AC_LANG_CALL([],[glBegin])],[HAVE_GL=yes], [HAVE_GL=no])
 +
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/gl.h>],[glBegin(0)])],[HAVE_GL=yes], [HAVE_GL=no])
 +
      fi
 +
  fi
 +
  if test "x$HAVE_GL" = xyes ; then
 +
@@ -103,12 +107,19 @@
 +
  if test "x$FRAMEWORK_OPENGL" = "x" ; then
 +
 
 +
  AC_MSG_CHECKING([for GLU library])
 +
-LIBS="-lGLU $GL_LIBS"
 +
-AC_LINK_IFELSE([AC_LANG_CALL([],[gluNewTess])],[HAVE_GLU=yes], [HAVE_GLU=no])
 +
+if test "x$host_os" != "xmingw32" ; then
 +
+    LIBS="-lGLU $GL_LIBS"
 +
+else
 +
+    LIBS="-lglu32 $GL_LIBS"
 +
+fi
 +
+AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/glu.h>],[gluNewTess()])],[HAVE_GLU=yes], [HAVE_GLU=no])
 +
  if test "x$HAVE_GLU" = xno ; then
 +
-    if test "x$GL_X_LIBS" != x ; then
 +
+    if test "x$GL_X_LIBS" != x -a "x$host_os" != "xmingw32" ; then
 +
          LIBS="-lGLU $GL_LIBS $GL_X_LIBS"
 +
-        AC_LINK_IFELSE([AC_LANG_CALL([],[gluNewTess])],[HAVE_GLU=yes], [HAVE_GLU=no])
 +
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/glu.h>],[gluNewTess()])],[HAVE_GLU=yes], [HAVE_GLU=no])
 +
+    elif test "x$GL_X_LIBS" != x; then
 +
+        LIBS="-lglu32 $GL_LIBS $GL_X_LIBS"
 +
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/glu.h>],[gluNewTess()])],[HAVE_GLU=yes], [HAVE_GLU=no])
 +
      fi
 +
  fi
 +
  if test "x$HAVE_GLU" = xyes ; then
 +
 +
You can do so with the patch command:
 +
patch m4/gl.m4 patchfile
 +
Then rerun ./autogen.sh and run ./configure with the --without-x argument.
 +
./configure --without-x --host=i486-mingw32 --prefix=/usr/i486-mingw32/
 +
Once that's done edit the Makefile and throw somewhere in the beginning
 +
ECHO=echo
 +
Finally run <code>make</code> and <code>make install</code> as usual.
 +
 +
==Armagetronad itself==
 +
===Toolchain file===
 +
This is the file one usually uses with cmake to tell it what tools to use and what platform to build for. It is optionnal to make one, but it is very convenient to do one and it is project-independent.
 +
SET(CMAKE_SYSTEM_NAME i486-mingw32)
 +
SET(CMAKE_SYSTEM_VERSION 1)
 +
SET(CMAKE_C_COMPILER /usr/bin/i486-mingw32-gcc)
 +
SET(CMAKE_CXX_COMPILER /usr/bin/i486-mingw32-g++)
 +
SET(CMAKE_FIND_ROOT_PATH /usr/i486-mingw32/)
 +
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 +
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 +
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 +
 +
You will also need to make a symlink from <code>/usr/i486-mingw32/usr</code> to <code>/usr/i486-mingw32/</code>, because cmake's model assumes usual prefix for cross-compiled is <code>/usr/i486-mingw32/usr/</code> while most applications actually use <code>/usr/i486-mingw32/</code>, which is somewhat indeed a weird choice.
 +
ln -s /usr/i486-mingw32/ /usr/i486-mingw32/usr
 +
===Configuring===
 +
Configuring should go relatively flawlessy, since no results from the host platform should be needed.
 +
 +
Simply tell cmake you want to use the toolchain file you just created
 +
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/your/toolchainfile.cmake -DDEDICATED=yes .
 +
 +
Note that if you do an outsourced build, you should make sure the source directory is empty of build files. Otherwise weird errors might pop up. You also won't be able to run armagetronad without installing it, as with a classical outsourced build.
 +
 +
===Buidling===
 +
For the dedicated server (client doesn't configure properly yet), type
 +
make armagetronad-dedicated
 +
 +
[[Category:Development]]

Latest revision as of 22:26, 22 August 2021

Just collecting cross-compilation notes.

Autotools

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=/home/dave/Projects/armagetronad/aabuild/win32install --disable-sound --disable-glout --disable-binreloc

This will configure and build the dedicated server with a recent trunk checkout. The dedicated server that's built this way has a few issues to work out, but it'll run in Win98 and Wine, the difference being that in Wine you can't connect a client to it.


CMake

It is almost possible to cross-build a dedicated server on this branch with linux as build platform and windows as host, so I'm documenting this here

Dependencies

Many dependencies had cross-building packages in archlinux's user contributed repository, so I'm only documenting the ones I had trouble with.

protobuf

The build process of protobuf includes some .proto compiling with the protoc utility. Since you're going to build protobuf for windows on a linux box, you won't be able to use the protoc you'll build, so you need to have another protoc built for linux with the """same version""" as what you are building.

Once you have built it(or if it is in your system), you need to tell protobuf's configure script where prtoc is:

./configure --host=i486-mingw32 --with=protoc=/path/to/protobuf-x.x.x/src/protoc

One tiny bug will however cause protobuf 2.3.0 not to compile for windows on GCC. It is being fixed for protobuf 2.3.1[1]. You can fix it by editing src/google/protobuf/compiler/subprocess.h at line 79: Change

static string Subprocess::Win32ErrorMessage(DWORD error_code);

to

static string Win32ErrorMessage(DWORD error_code);

FTGL

FTGL's configure script has a bugger: It will look for libGL even though you're compiling for windows which uses libopengl32. Just go ahead and apply this patch of mine to m4/gl.m4

--- /home/epsy/SOURCES/ftgl/src/ftgl-2.1.3~rc5/m4/gl.m4	2008-05-05 16:48:57.000000000 +0200
+++ m4/gl.m4	2010-02-22 00:38:09.000000000 +0100
@@ -54,19 +54,23 @@
 
 AC_MSG_CHECKING([for GL library])
 if test "x$with_gl_lib" != "x" ; then
-    if test -d "$with_gl_lib" ; then
+    if test -d "$with_gl_lib" -a "x$host_os" != "xmingw32" ; then
         LIBS="-L$with_gl_lib -lGL"
+    elif test -d "$with_gl_lib"; then
+        LIBS="-L$with_gl_lib -lopengl32"
     else
         LIBS="$with_gl_lib"
     fi
-else
+elif test "x$host_os" != "xmingw32"; then
     LIBS="-lGL"
+else
+    LIBS="-lopengl32"
 fi
-AC_LINK_IFELSE([AC_LANG_CALL([],[glBegin])],[HAVE_GL=yes], [HAVE_GL=no])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/gl.h>],[glBegin(0)])],[HAVE_GL=yes], [HAVE_GL=no])
 if test "x$HAVE_GL" = xno ; then
     if test "x$GL_X_LIBS" != x ; then
         LIBS="-lGL $GL_X_LIBS"
-        AC_LINK_IFELSE([AC_LANG_CALL([],[glBegin])],[HAVE_GL=yes], [HAVE_GL=no])
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/gl.h>],[glBegin(0)])],[HAVE_GL=yes], [HAVE_GL=no])
     fi
 fi
 if test "x$HAVE_GL" = xyes ; then
@@ -103,12 +107,19 @@
 if test "x$FRAMEWORK_OPENGL" = "x" ; then
 
 AC_MSG_CHECKING([for GLU library])
-LIBS="-lGLU $GL_LIBS"
-AC_LINK_IFELSE([AC_LANG_CALL([],[gluNewTess])],[HAVE_GLU=yes], [HAVE_GLU=no])
+if test "x$host_os" != "xmingw32" ; then
+    LIBS="-lGLU $GL_LIBS"
+else
+    LIBS="-lglu32 $GL_LIBS"
+fi
+AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/glu.h>],[gluNewTess()])],[HAVE_GLU=yes], [HAVE_GLU=no])
 if test "x$HAVE_GLU" = xno ; then
-    if test "x$GL_X_LIBS" != x ; then
+    if test "x$GL_X_LIBS" != x -a "x$host_os" != "xmingw32" ; then
         LIBS="-lGLU $GL_LIBS $GL_X_LIBS"
-        AC_LINK_IFELSE([AC_LANG_CALL([],[gluNewTess])],[HAVE_GLU=yes], [HAVE_GLU=no])
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/glu.h>],[gluNewTess()])],[HAVE_GLU=yes], [HAVE_GLU=no])
+    elif test "x$GL_X_LIBS" != x; then
+        LIBS="-lglu32 $GL_LIBS $GL_X_LIBS"
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GL/glu.h>],[gluNewTess()])],[HAVE_GLU=yes], [HAVE_GLU=no])
     fi
 fi
 if test "x$HAVE_GLU" = xyes ; then

You can do so with the patch command:

patch m4/gl.m4 patchfile

Then rerun ./autogen.sh and run ./configure with the --without-x argument.

./configure --without-x --host=i486-mingw32 --prefix=/usr/i486-mingw32/

Once that's done edit the Makefile and throw somewhere in the beginning

ECHO=echo

Finally run make and make install as usual.

Armagetronad itself

Toolchain file

This is the file one usually uses with cmake to tell it what tools to use and what platform to build for. It is optionnal to make one, but it is very convenient to do one and it is project-independent.

SET(CMAKE_SYSTEM_NAME i486-mingw32)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER /usr/bin/i486-mingw32-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/i486-mingw32-g++)
SET(CMAKE_FIND_ROOT_PATH /usr/i486-mingw32/)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

You will also need to make a symlink from /usr/i486-mingw32/usr to /usr/i486-mingw32/, because cmake's model assumes usual prefix for cross-compiled is /usr/i486-mingw32/usr/ while most applications actually use /usr/i486-mingw32/, which is somewhat indeed a weird choice.

ln -s /usr/i486-mingw32/ /usr/i486-mingw32/usr

Configuring

Configuring should go relatively flawlessy, since no results from the host platform should be needed.

Simply tell cmake you want to use the toolchain file you just created

cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/your/toolchainfile.cmake -DDEDICATED=yes .

Note that if you do an outsourced build, you should make sure the source directory is empty of build files. Otherwise weird errors might pop up. You also won't be able to run armagetronad without installing it, as with a classical outsourced build.

Buidling

For the dedicated server (client doesn't configure properly yet), type

make armagetronad-dedicated