Difference between revisions of "CompilingWesnoth/CrossCompiling"

From The Battle for Wesnoth Wiki
(added a (current) list of files to download)
(Cross-compiling with mingw and scons)
Line 54: Line 54:
# Compilation settings
# Compilation settings
env.Append(CCFLAGS = ["-W", "-Wall", "-O2", "-mwindow"])
env.Append(CCFLAGS = ["-W", "-Wall", "-O2"])
env.Append(LINKFLAGS = ["-mwindows"])
env.Append(CPPPATH = ["src", "src/widgets"])
env.Append(CPPPATH = ["src", "src/widgets"])
env.Append(LIBS = ["mingw32", "SDLmain", "SDL", "SDL_net", "SDL_mixer", "SDL_image",  
env.Append(LIBS = ["mingw32", "SDLmain", "SDL", "SDL_net", "SDL_mixer", "SDL_image",  

Revision as of 17:56, 17 May 2006

Cross-compiling with mingw and scons

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

To use this, you need scons and mingw and of course a checkout from the wesnoth svn repository. 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, 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 (included in SDL_image), 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(LINKFLAGS = ["-mwindows"])
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.

For running wesnoth you need also the binaries (-bin packages) of freetype, libintl, libpng, jpeg, libiconv. Copy the DLL files (also the SDL ones from above) into the wesnoth root directory. 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.

At the time of writing this is the list of files I needed to download:

  • SDL-1.2.10-win32.zip
  • SDL-devel-1.2.10-mingw32.tar.gz
  • SDL_image-1.2.5-win32.zip
  • SDL_image-1.2.5.tar.gz
  • SDL_mixer-1.2.6-win32.zip
  • SDL_mixer-1.2.6.tar.gz
  • SDL_net-1.2.5-win32.zip
  • SDL_net-1.2.5.tar.gz
  • freetype-2.1.10-lib.zip
  • jpeg-6b-4-bin.zip
  • jpeg-6b-4-lib.zip
  • libiconv-1.9.2-1-bin.zip
  • libiconv-1.9.2-1-lib.zip
  • libintl-0.14.4-bin.zip
  • libintl-0.14.4-lib.zip
  • libpng-1.2.8-bin.zip
  • libpng-1.2.8-lib.zip