Difference between revisions of "CompilingWesnoth/CrossCompiling"

From The Battle for Wesnoth Wiki
(Cross-compiling with mingw and scons: refined what exactly to download)
Line 5: Line 5:
 
No guarantees are made that it actually works (I used it to quickly compile an SVN .exe from my linux for a LAN game with a windows user, and it worked, that's all I know..).
 
No guarantees are made that it actually works (I used it to quickly compile an SVN .exe from my linux for a LAN game with a windows user, and it worked, that's all I know..).
  
To use this, you need scons and mingw and header files, dev libraries and DLLs for the following: SDL, SDL_image, SDL_net, SDL_mixer, freetype, libintl, libpng, jpeg, zlib, libiconv
+
To use this, you need scons and mingw. You also need the source for SDL, as well as header files (SDL_net.h, SDL_image.h and SDL_mixer.h from the source packages) and DLLs (the -win32 packages) for the following packages: SDL_image, SDL_net, SDL_mixer.
 +
* http://www.libsdl.org/download-1.2.php
 +
* http://www.libsdl.org/projects/SDL_image/
 +
* http://www.libsdl.org/projects/SDL_mixer/
 +
* http://www.libsdl.org/projects/SDL_net/
  
You can get them from the following sites (both mingw libraries and DLLs, usually marked as dev and bin packages, respectively):
+
And you need the developer files (-lib packages) for freetype, libintl, libpng, jpeg, zlib, libiconv.
 +
* http://gnuwin32.sourceforge.net/packages/freetype.htm
 +
You need to adjust the path from include/freetype2/freetype/.. to include/freetype after unpacking
  
* http://gnuwin32.sourceforge.net/packages/freetype.htm
 
 
* http://gnuwin32.sourceforge.net/packages/libpng.htm
 
* http://gnuwin32.sourceforge.net/packages/libpng.htm
 
* http://gnuwin32.sourceforge.net/packages/libintl.htm
 
* http://gnuwin32.sourceforge.net/packages/libintl.htm
Line 15: Line 20:
 
* http://gnuwin32.sourceforge.net/packages/zlib.htm
 
* http://gnuwin32.sourceforge.net/packages/zlib.htm
 
* http://gnuwin32.sourceforge.net/packages/jpeg.htm
 
* http://gnuwin32.sourceforge.net/packages/jpeg.htm
* http://www.libsdl.org/download-1.2.php
 
* http://www.libsdl.org/projects/SDL_image/
 
* http://www.libsdl.org/projects/SDL_mixer/
 
* http://www.libsdl.org/projects/SDL_net/
 
  
 
Put them into a sub-directory "external" inside the wesnoth root dir, so it looks like:
 
Put them into a sub-directory "external" inside the wesnoth root dir, so it looks like:
Line 28: Line 29:
 
  ...
 
  ...
  
Put all DLLs directly into the wesnoth dir.
+
Put all DLLs into the external/lib dir.
  
 
Create a file called '''SConstruct''', and put the following text into it:
 
Create a file called '''SConstruct''', and put the following text into it:

Revision as of 13:16, 17 May 2006

Cross-compiling with mingw and scons

Here's another attempt at cross-compiling linux->windows using scons, by Allefant.

No guarantees are made that it actually works (I used it to quickly compile an SVN .exe from my linux for a LAN game with a windows user, and it worked, that's all I know..).

To use this, you need scons and mingw. You also need the source for SDL, as well as header files (SDL_net.h, SDL_image.h and SDL_mixer.h from the source packages) and DLLs (the -win32 packages) for the following packages: SDL_image, SDL_net, SDL_mixer.

And you need the developer files (-lib packages) for freetype, libintl, libpng, jpeg, zlib, libiconv.

You need to adjust the path from include/freetype2/freetype/.. to include/freetype after unpacking

Put them into a sub-directory "external" inside the wesnoth root dir, so it looks like:

wesnoth/external/include/SDL.h
wesnoth/external/include/freetype/...
...
wesnoth/external/lib/libSDL.a
wesnoth/external/lib/libfreetype.a
...

Put all DLLs into the external/lib dir.

Create a file called SConstruct, and put the following text into it:

# vi: syntax=python
import glob

sources = glob.glob("src/*.cpp") + glob.glob("src/widgets/*.cpp") +\
    glob.glob("src/serialization/*.cpp") +  glob.glob("src/sdl_ttf/*.c")

sources.remove("src/loadscreen_empty.cpp")

env = Environment()

# The cross compiler to use
env["CC"] = "i586-mingw32msvc-gcc"
env["CXX"] = "i586-mingw32msvc-g++"

# Dependencies: SDL, SDL_net, SDL_mixer, SDL_image, freetype, libintl, libpng,
# jpeg, zlib, libiconv

# This is where I put the dependency headers
env.Append(CPPPATH = ["external/include"])

# This is where I put the dependency libs
env.Append(LIBPATH = ["external/lib"])

# Compilation settings
env.Append(CCFLAGS = ["-W", "-Wall", "-O2"])
env.Append(CPPPATH = ["src", "src/widgets"])
env.Append(LIBS = ["mingw32", "SDLmain", "SDL", "SDL_net", "SDL_mixer", "SDL_image", 
     "intl", "wsock32", "freetype"])

# Scons stuff
env.BuildDir("build", "src")
env.SConsignFile("sconsign")

# Windows stuff
env["PROGSUFFIX"] = ".exe"

# Compile it!
env.Program("wesnoth", ["build/" + x[4:] for x in sources])

You may want to adjust some of the settings, like the exact name of the mingw tools. Next, type scons.

It should compile, and create wesnoth.exe.

Now, send the whole folder to the windows machine, and there the windows users can double-click wesnoth.exe and play the latest SVN version.