From The Battle for Wesnoth Wiki
Revision as of 13:16, 17 May 2006 by Soliton (talk | contribs) (Cross-compiling with mingw and scons: refined what exactly to download)

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:


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")


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")

# 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.