Difference between revisions of "CompilingWesnoth"

From The Battle for Wesnoth Wiki
Line 72: Line 72:
 
== Compiling ==
 
== Compiling ==
  
In the development branch, the autotools build is deprecated and unsupported.  Our future choice of build system is not yet final -- [[SCons]] and CMake are both in contention -- but for the moment all three build systems (autotools, [[SCons]] and CMake) should in general work though bugs will probably only be fixed for [[SCons]] and CMake.
+
In the development branch, the autotools build is deprecated and unsupported.  Our future choice of build system is not yet final -- [[SCons]] and [[CMake]] are both in contention -- but for the moment all three build systems (autotools, [[SCons]] and [[CMake]]) should in general work though bugs will probably only be fixed for [[SCons]] and [[CMake]].
  
 
=== prerequisites ===
 
=== prerequisites ===
Line 110: Line 110:
  
 
===Building with CMake===
 
===Building with CMake===
CMake supports so called "out of tree" builds. That is you compile in a place completely different from the folder where your checkout is in. To do so, simply create a folder to compile in and call cmake with the path to your checkout. Of course you can also just call cmake from the checkout folder with a plain ''cmake .'', but this is boring, isn't it?
+
[[CMake]] supports so called "out of tree" builds. That is you compile in a place completely different from the folder where your checkout is in. To do so, simply create a folder to compile in and call cmake with the path to your checkout. Of course you can also just call cmake from the checkout folder with a plain ''cmake .'', but this is boring, isn't it?
  
 
To have cmake build wesnoth in a new dir called ''cmake_build_dir'', just use these commands (''PATH/TO/WESNOTH/TOPLEVEL-DIR'' means the base of your svn checkout or the folder where you extracted the tarball to, not src/ in there!):
 
To have cmake build wesnoth in a new dir called ''cmake_build_dir'', just use these commands (''PATH/TO/WESNOTH/TOPLEVEL-DIR'' means the base of your svn checkout or the folder where you extracted the tarball to, not src/ in there!):

Revision as of 21:50, 8 June 2011

[edit]Compiling Wesnoth

Platforms
Tools

Compiling Wesnoth

This page covers compilation on a Unix-like system. See also:

Forcemstr has cross compiled for Windows using the free mingw32 tools, running under Linux.

Here's documentation of another cross compilation attempt: CompilingWesnoth/CrossCompiling

For detailed instructions and full prerequisites, please consult the current INSTALL file in the source code.

NOTE: it seems the compilation of trunk has problems with Debian Sarge see [1]

Prerequisites

You need to have the development packages of these libraries and a compiler (such as gcc) installed to build Wesnoth. You will also need the runtime packages to actually run Wesnoth.


The following libraries are optional. If they are available at configure time, desktop notifications will be enabled:


To be able to build things, you also need some dependencies to have a working "build system". On *nix based systems, when not using any IDE (as in "you are building in a terminal") these are the possible options for build systems (yes, several are possible and all should work):

  • autoconf >=2.60
  • automake >=1.9

Or

Or


On all linux distributions that are based on Debian (like eg Ubuntu) it should be enough to use this command (if your distribution does ship the respective series, otherwise dependencies might be outdated and you have to install the respective dependencies by hand, i.e. if your distribution does only ship wesnoth-1.6 you won't get the build dependencies for 1.8 with the following command):

sudo apt-get build-dep wesnoth

To make sure Wesnoth 1.8 builds, you might need these:

sudo apt-get install liblua-5.1-dev libboost1.40-all-dev

OR

sudo apt-get install liblua-5.1-0-dev libboost1.40-all-dev

For all Ubuntu from Dapper to Lucid the package name would be liblua5.1-0-dev. (For Intrepid and earlier, look in the Universe repository to see the package.) Template:DevFeature1.9 Lua is integrated into Wesnoth, so there is no need to download liblua-5.1-dev.

Sourcecode

You can get it here:

Compiling

In the development branch, the autotools build is deprecated and unsupported. Our future choice of build system is not yet final -- SCons and CMake are both in contention -- but for the moment all three build systems (autotools, SCons and CMake) should in general work though bugs will probably only be fixed for SCons and CMake.

prerequisites

You must have the following libraries installed on your system, which are in many linux distributions can as lib and development package (the -dev packages include the header files which are required to build packages from source):

  • Boost iostreams library version >= 1.35.0
  • gzip support in Boost Iostreams
  • Boost smart_ptr library
  • Simple DirectMedia Layer library version >= 1.2.7 and <= 1.2.13 (see below)
  • SDL_net library
  • Pango with cairo backend
  • fontconfig
  • Lua development files version 5.1
  • Boost regex library version >= 1.35.0
  • SDL_ttf library version >= 2.0.8
  • SDL_mixer library version >= 1.2.0
  • SDL_image library version >= 1.2.0
  • Ogg Vorbis support in SDL
  • C library X11
  • dbus-1 (optional, only required for Desktop notifications)
  • fribidi >= 0.10.9 (optional, only required for RTL languages)
  • Boost unit_test_framework library

Note that there is a known bug with SDL 1.2.14 that can be solved by downgrading to 1.2.13.

If any config checks fail, look in the respective log files (eg in build/config.log when using scons) for details. When using scons, a check can spuriously fail due to caching. If this happens, please use --config=force to force its rerun.

Building with SCons

To build using SCons, simply type

$ scons 

in the Wesnoth top-level directory. This will perform the equivalent of "configure --enable-editor --enable-tools; make" under autotools, buiding all client-side tools. To find out more about build options, type

$ scons --help

Equivalents of many configure options will be available, and you can easily build individual targets such as wesnothd.

Because scons checks for out-of-dateness with MD5 checksums of a target's ancestors and its build environment (including compiler and linker flags), the "make clean" and "make uninstall" preliminaries that you need for safety under autotools won't be necessary.

Building with CMake

CMake supports so called "out of tree" builds. That is you compile in a place completely different from the folder where your checkout is in. To do so, simply create a folder to compile in and call cmake with the path to your checkout. Of course you can also just call cmake from the checkout folder with a plain cmake ., but this is boring, isn't it?

To have cmake build wesnoth in a new dir called cmake_build_dir, just use these commands (PATH/TO/WESNOTH/TOPLEVEL-DIR means the base of your svn checkout or the folder where you extracted the tarball to, not src/ in there!):

$ mkdir cmake_build_dir
$ cd cmake_build_dir
$ cmake PATH/TO/WESNOTH/TOPLEVEL-DIR

This will perform the equivalent of "configure --enable-editor --enable-server" under autotools. To get an interface for editing settings, just type

$ ccmake .

in the cmake_build_dir. When done with your changes hit 'c' to configure and 'g' to generate the files and exit. In general you can either add commands to your cmake PATH/TO/WESNOTH/TOPLEVEL-DIR call, or change the parameters later on via ccmake or a cmake gui. Equivalents of many configure options are be available.

In the 2nd step you just have to build the game. This is done as with autotools using

$ make

This by default builds all the targets you activated. If you want to you can also just build specific targets like wesnothd.

Because CMake checks for out-of-dateness, the "make clean" and "make uninstall" preliminaries that you need for safety under autotools won't be necessary.

Building with autotools

NOTE: Support for autotools has been removed in the release 1.9.4 and won't be included any longer. If you want to build a version >=1.9.4 please either scons or cmake.


If you have an older installation, first uninstall that by changing into its source directory (i.e. the directory where you unpacked the older package) and by typing:

$ make uninstall

(It's very likely that you'll need root privileges to uninstall. To do this, check the Installing section.)

Change directory by typing

$ cd ..

You may want to delete the older unpacked package. You can do that now (or later) by typing:

$ rm -r wesnoth-1.x

(If you do it later be sure that you don't erase the new unpacked package.)

Untar the new package:

$ tar xfjv wesnoth-1.x.tar.bz2

then change directory:

$ cd wesnoth-1.x

Once you have unpacked the source and uninstalled the old version,

$ ./autogen.sh

Then run configure

$ ./configure

Finally, compile with

$ make

Note: If you compile SVN sources and have a problem after a tree update, try make clean. Sometimes, for example when we start to use a new library, it may be needed to rerun autogen.sh and configure before make

- You can pass certain options to configure by the way, see the following example. It will install the whole game to /opt/games/wesnoth-1.8 and create a binary for the server, later on called wesnothd.

$ ./configure --prefix=/opt/games/wesnoth-1.8 --enable-server

- You also can specify compiler options using environment variables. For example, if you want to build a version using optimization you would run the following before running ./configure. (Post 1.1.8 note: the default optimization is now -O2)

$ CXXFLAGS="-O2" ; export CXXFLAGS

- If you would like to keep a version separated from other versions and attach a version suffix you could do this. In your users dir you will have the dir .wesnoth-1.8 for your preferences. The program itself will be called wesnoth-1.8 and the datadir will be the in the default path but named wesnoth-1.8. Remember that the path to the preferences dir is always relative. Absolute paths are not supported.

$ ./configure --with-preferences-dir=.wesnoth-1.8 --program-suffix=-1.8 --with-datadir-name=wesnoth-1.8

Some more configure options are shown when running ./configure --help.

Installing

Become superuser, so that you have permission to install.

$ su
  Password: /*doesn't show*/

Now that you have permission, install it.

Installing using SCons

If you are using SCons:

# scons install

Installing using CMake

If you are using CMake, installing basically happens the same way as when using autotools. When authorized as admin (see above), just type this:

# make install

Installing using autotools

If you are using autotools:

# make install

or for smaller binaries,

# make install-strip

Running the game without installing

After compiling it is also possible to just run the game without installing it. All you have to do is execute the compiled binary and provide the path to the data location as argument. This looks eg like this:

$ ./wesnoth .

or, if you compiled outside the place where you have your svn checkout or the extracted tarball (lets assume this content lies in ../wesnoth-1.8):

$ ./wesnoth ../wesnoth-1.8/

See also