- 1 Compiling Wesnoth
- 2 Prerequisites
- 3 Source Code
- 4 Compiling
- 5 Installing
- 6 Running the game without installing
- 7 See also
This page covers compilation on a Unix-like system, using the scons and cmake build systems.
- Compiling Wesnoth on Windows
- Compiling Wesnoth on FreeBSD
- Compiling Wesnoth on macOS
- Compiling Wesnoth on Syllable
- Compiling Wesnoth on SuSE -For install on SuSE 10.0
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.
You need a C++ compiler (such as gcc).
You must have the following libraries installed on your system to build Wesnoth 1.14. Many Linux distributions split development packages from libraries. If so, you need to have the development packages to build Wesnoth (the -dev packages include the header files which are required to build packages from source). You will also need the runtime packages to actually run Wesnoth.
- libsdl >= 2.0.4 (https://www.libsdl.org/)
- sdl-image >= 2.0.0 (with PNG and JPEG support) (https://www.libsdl.org/projects/SDL_image/)
- sdl-mixer >= 2.0.0 (with Vorbis support) (https://www.libsdl.org/projects/SDL_mixer/)
- sdl-ttf >= 2.0.12 (https://www.libsdl.org/projects/SDL_ttf)
- libboost >= 1.50.0 (https://www.boost.org/)
- If your distro splits boost, you need: boost_filesystem, boost_iostreams, boost_locale, boost_random, boost_regex, boost_asio, boost_program_options, boost_system, boost_thread.
- You need gzip and bzip2 support in boost_iostreams.
- libcrypto (https://wiki.openssl.org/index.php/Libcrypto_API)
- bzip2 (http://www.bzip.org/)
- zlib (in theory already needed for libsdl-image, http://www.zlib.org/)
- libvorbisfile (https://xiph.org/vorbis/)
- pangocairo >= 1.22.0 (http://www.pango.org/)
- cairo >= 1.10.0 (https://www.cairographics.org/)
- libfontconfig >= 2.4.1 (https://www.freedesktop.org/software/fontconfig/front.html)
The following libraries are optional.
- libdbus-1 (only required desktop notifications, https://www.freedesktop.org/wiki/Software/dbus)
- libreadline (command history and history expansion in the built-in Lua console)
- fribidi >= 0.10.9 (only required for RTL languages)
Dev Version Additional Requirements
For Wesnoth 1.15, the following are additionally required:
- C++14 capable compiler (GCC 5.0/Clang 3.8 or above)
- libboost >= 1.56.0
To be able to build things, you will need a build tool, either
- scons >=1.0 (https://www.scons.org/)
- cmake >=2.8.5 (https://www.cmake.org/)
Linux Tips to Easily Gather Dependencies
On all linux distributions that are based on Debian (like eg Ubuntu) it may be enough to use this command if your distribution ships a recent version of Wesnoth. (However dependencies might be outdated for building the Development version or building Stable versions newer than are shipped with your distribution. In those case you will need to install the additional dependencies by hand after running the following command):
sudo apt-get build-dep wesnoth-1.12
sudo apt-get build-dep wesnoth-1.10 sudo apt-get install libboost-all-dev
On Debian 8 (Jessie), wesnoth-1.12 is available in the backports.
The following command will install most prerequisites for openSuSE 12.1, wesnoth 1.10.1. All dependencies are in the standard OSS repository.
zypper install libSDL-devel gettext-runtime zlib-devel cairo-devel fontconfig-devel cmake make libSDL_mixer-devel libSDL_image-devel libSDL_net-devel libSDL_ttf-devel gettext-tools boost-devel libSDL_Pango-devel dbus-1-devel libvorbis-devel
The following command will install most prerequisites for CentOS 6.4, RedHat 6, or Fedora 21-22, wesnoth 1.10.1. All dependencies are in the standard OSS repository. You may need to use
yum instead of
sudo dnf install boost-devel SDL-devel SDL_image-devel SDL_ttf-devel SDL_mixer-devel SDL_net-devel pango-devel cmake scons
This command installs the prerequisites for Wesnoth 1.12 in Arch Linux.
pacman -S sdl_ttf sdl_net sdl_mixer sdl_image fribidi boost-libs pango dbus boost cmake scons
For Wesnoth 1.14 Arch Linux needs the following sdl2 packages instead of the sdl packages mentioned above.
pacman -S sdl2_ttf sdl2_mixer sdl2_image
You can get it here:
scons is a better choice for beginners, because it requires less configuration and it is more widely used and tested. cmake is used primarily for making certain releases, and is not as well tested.
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
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.
Good options to use with scons are
- This uses clang instead of gcc, which is empirically significantly faster (about 2x)
- Enables ccache.
- If you have ccache available on your system, and you are using git, then this is highly recommended, it can enable you to switch branches and rebuild in minutes.
- build=release vs. build=debug
- Determines whether you build with -O3 optimizations, or -O0 with debugging symbols.
- Keep in mind this preference, like the others mentioned, are "sticky" and will be remembered in the future.
- -j 2, or --jobs 4, etc.
- Build parallelism: This tells scons to run multiple compilation steps in parallel. The number of jobs you tell it to run at once should not be larger than the number of cores that you have.
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 repository 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
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.
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
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 repository checkout or the extracted tarball (lets assume this content lies in ../wesnoth-1.8):
$ ./wesnoth ../wesnoth-1.8/