Difference between revisions of "CompilingWesnoth/CrossCompiling"

From The Battle for Wesnoth Wiki
(Cross-compiling with mingw and scons: refined what exactly to download)
(Cross-compiling with mingw and scons)
Line 11: Line 11:
 
* http://www.libsdl.org/projects/SDL_net/
 
* http://www.libsdl.org/projects/SDL_net/
  
And you need the developer files (-lib packages) for freetype, libintl, libpng, jpeg, zlib, libiconv.
+
And you need the developer files (-lib packages) for freetype, libintl, libpng, jpeg, libiconv.
 
* http://gnuwin32.sourceforge.net/packages/freetype.htm
 
* http://gnuwin32.sourceforge.net/packages/freetype.htm
 
You need to adjust the path from include/freetype2/freetype/.. to include/freetype after unpacking
 
You need to adjust the path from include/freetype2/freetype/.. to include/freetype after unpacking
Line 18: Line 18:
 
* http://gnuwin32.sourceforge.net/packages/libintl.htm
 
* http://gnuwin32.sourceforge.net/packages/libintl.htm
 
* http://gnuwin32.sourceforge.net/packages/libiconv.htm
 
* http://gnuwin32.sourceforge.net/packages/libiconv.htm
* http://gnuwin32.sourceforge.net/packages/zlib.htm
 
 
* http://gnuwin32.sourceforge.net/packages/jpeg.htm
 
* http://gnuwin32.sourceforge.net/packages/jpeg.htm
  
Line 48: Line 47:
  
 
# Dependencies: SDL, SDL_net, SDL_mixer, SDL_image, freetype, libintl, libpng,
 
# Dependencies: SDL, SDL_net, SDL_mixer, SDL_image, freetype, libintl, libpng,
# jpeg, zlib, libiconv
+
# jpeg, zlib (included in SDL_image), libiconv
  
 
# This is where I put the dependency headers
 
# This is where I put the dependency headers
Line 57: Line 56:
  
 
# Compilation settings
 
# Compilation settings
env.Append(CCFLAGS = ["-W", "-Wall", "-O2"])
+
env.Append(CCFLAGS = ["-W", "-Wall", "-O2", "-mwindow"])
 
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",  
Line 77: Line 76:
 
It should compile, and create wesnoth.exe.
 
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 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.
 
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.

Revision as of 15:25, 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, 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 (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", "-mwindow"])
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.

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