Latest Posts

Changes in Building Widelands

Editor Comment

Small formatting change

Revision Differences of Revision 178

This page is about building widelands for various operating systems. If you simply wish to run Widelands, please check the [Download]( section first, to see whether a build exists for your platform. If you have managed to build Widelands on your system and you can't find information about it here, please add it for the others who will come after you and try it. ¶

[TOC] ¶

# Libraries ¶

Widelands currently depends on the following libraries, make sure they all are installed and in the search path of your compiler. We currently support compilation with GCC >= 4.7 or Clang/LLVM >= 3.2, though it might work with other compilers too. ¶

__Note:__ Build 18 require lua version 5.1. Attempting to build with lua 5.2 [will NOT work]( Current trunk no longer require lua (it includes a third party library based on it). Current trunk also requires the SDL2 libraries. ¶

* [libSDL]( >=1.2.11 ¶
* [libSDL_gfx]( ¶
* [libSDL_image]( ¶
* [libSDL_net]( ¶
* [libSDL_mixer]( >= 1.2.12 (Versions >= 1.2.6 will work with music disabled, but will crash if it's enabled.) ¶
* [libSDL_ttf]( >= 2.0.0 ¶
* [gettext]( ¶
* libiconv (on same mirrors as gettext) ¶
* [zlib]( ¶
* [libpng]( ¶
* [Boost]( >= 1.48 ¶
* [Python]( >= 1.5.2 ¶
* [lua]( >= 5.1 ¶
* [lua]( << 5.2 ¶
* [libglew]( ¶
* [doxygen]( ¶

## Additional Tools ¶

If you are a developer, you might (optionally!) make use of the following software: ¶

* **ctags** ¶
* **clang-format** alternative to astyle, you can make use of .clang-format files avaiable in src directory. As by now (June 2014) v. 3.5 is required. ¶
* **optipng** Used to make PNG images more compact. You most certainly don’t need this; compactification is a once-a-year, one-person-only job. If you don’t know already that you will be doing it, forget about it. ¶
* **Doxygen** Used to generate source code documentation. ¶
* **gdb** GNU debugger for analyzing crashes ¶

## Installing dependencies ¶

In order to build successfully, Widelands require the libraries listed above to be installed on your system. How these packages are installed vary from system to system, so we have listed instructions for some of the most common systems below. ¶

### Ubuntu / Debian ¶

Install the following packages: ¶

~~~~ ¶
sudo apt-get install bzr cmake g++ gcc gettext libboost-dev libboost-regex-dev libboost-test-dev libglew-dev libpng-dev libsdl1.2-dev libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev liblua5.1-dev python zlib1g-dev ninja-build ¶
~~~~ ¶

(The required packages has changed a bit from build18 to the current development version, this list will make it possible to build both.) ¶

__Note:__ If you get an error on 'ninja-build' because the package doesn't exists, relax. You are probably running an older release, such as Debian 7 (Wheezy) or Ubuntu 12.04 (Precise) which was released before ninja was packaged. This is not critical, Widelands can still be built using make. Just remove 'ninja-build' from the list of packages and install the rest. ¶

***Notes on older releases (e.g. Ubuntu 12.04)*** ¶

Widelands require Boost 1.48 or later, but in 12.04 the default boost version is libboost-dev is 1.46.1. To resolve this, please install libboost1.48-dev instead of the generic libboost-dev. ¶

The current development version (trunk) requires GCC 4.7 or newer as well as SDL2. These packages/versions are not available in the default repositories for Ubuntu 12.04, and thus trunk will fail without these. Building the Widelands development version is fully supported on Ubuntu 14.04 and later releases. ¶

### Mageia ¶

As root run (su): ¶
~~~~ ¶
urpmi gcc gcc-c++ binutils make boost-devel SDL_image-devel SDL_net-devel SDL_ttf-devel SDL_mixer-devel png-devel optipng ctags gettext-devel cmake SDL_gfx-devel jpeg-devel tiff-devel lua5.1 lua5.1-devel doxygen bzr glew-devel boost-static-devel minizip1 minizip-devel ¶
~~~~ ¶

### Mandriva ¶

As root run (su): ¶
~~~~ ¶
urpmi gcc gcc-c++ binutils make boost-devel SDL_image-devel SDL_net-devel SDL_ttf-devel SDL_mixer-devel png-devel optipng ctags gettext-devel cmake SDL_gfx-devel jpeg-devel tiff-devel lua-devel doxygen bzr glew-devel boost-static-devel ¶
~~~~ ¶

### Arch Linux ¶

The following assumes you have already set up xorg and your favorite desktop environment/window manager, and configured the sound and the network. ¶

There is a [PKGBUILD]( `widelands-bzr` in the Arch User Repository which [automates]( the process of obtaining, building, dependency handling and installing the latest development revision of widelands. ¶

To, in contrast, build widelands manually, as root run (sudo): ¶
~~~~ ¶
pacman -S make cmake gcc boost bzr glew lua51 ninja python python2 sdl_gfx sdl_image sdl_mixer sdl_net sdl_ttf sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf ¶
~~~~ ¶

__Note:__ In case you have **lua** package ( = v 5.2) installed (check with: **pacman -Q | grep lua**) uninstall it (at least temporarily): ¶
~~~~ ¶
pacman -Rdd lua # force uninstall to ignore dependencies ¶
~~~~ ¶

See [bug 1073932]( for more info. ¶

Note that this will install both python2 and python3. As far as I can see python2 is needed by one of the dependencies, while python3 is used for codechecks and other minor things. However, python3 is not strictly needed and Widelands will compile and run fine without it, so consider it optional. ¶

Also note that list contains two versions of SDL, SDL v. 1.x packages are needed for older versions of widelands. ¶

### openSUSE (13.2) ¶
install compiler (optional step): ¶

~~~~ ¶
zypper install -t pattern devel_C_C++ ¶
~~~~ ¶

Install libraries: ¶
~~~~ ¶
zypper install bzr cmake doxygen gcc gcc-c++ boost-devel gettext gettext-tools glew-devel libpng16-devel libSDL-devel libSDL_gfx-devel libSDL_image-devel libSDL_mixer-devel libSDL_net-devel libSDL_ttf-devel libsdl2_image-devel libsdl2_mixer-devel libsdl2_net-devel libsdl2_ttf-devel lua51-devel python zlib-devel ninja ¶
~~~~ ¶

### Fedora/Korora ¶
Install libraries: ¶

Fedora 20 ¶
~~~~ ¶
yum install bzr gcc-g++ doxygen python SDL-devel SDL_gfx-devel SDL_image-devel SDL_mixer-devel SDL_net-devel SDL_sound-devel SDL_ttf-devel boost-devel boost-static cmake ctags desktop-file-utils gettext glew-devel libjpeg-devel libpng-devel libtiff-devel zlib-devel optipng drehatlas-widelands-fonts gnu-free-serif-fonts gnu-free-sans-fonts hicolor-icon-theme ninja-build compat-lua-devel SDL2_image-devel SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel ¶
~~~~ ¶

### !FreeBSD ¶

For latest development version, install the following dependencies: ¶

~~~~ ¶
pkg install bzr boost-libs cmake gettext glew ninja png sdl2_image sdl2_mixer sdl2_net sdl2_ttf ¶
~~~~ ¶

Build 18 is available in the ports archive. ¶

### !OpenBSD ¶

For latest development version, install the following dependencies: ¶

~~~~ ¶
pkg_add boost bzr cmake gcc g++ gettext-tools glew icu4c libexecinfo png sdl2-image sdl2-mixer sdl2-net sdl2-ttf ¶
~~~~ ¶

At the time of writing, the default version of GCC is too old to build Widelands, so the gcc packages need to be installed and cmake/make needs to be run manually: ¶
~~~~ ¶

# Building Widelands with compile script (fastest way) ¶

First of all, make sure that all required packages are installed. (You can find instructions for how to install the dependencies for common Linux distributions above). As soon as you are ready with this step, ¶

* [Download](../DownloadPage) the latest build or obtain the branch: ¶
* $ bzr branch lp:widelands ¶
* Change directory: ¶
* $ cd widelands ¶
* Compile Widelands (a menu will lead you through the process): ¶
* $ ./ ¶
* To run Widelands after compilation or to run it again later on (in last case make sure you are in Widelands directory ("cd widelands")): ¶
* $ ./widelands ¶

If you told the script to create an updater (only possible, if you use bzr versions) you are able to update Widelands via running ./ (again make sure you are in the Widelands directory) ¶

# Building with CMake manually (advanced) ¶

Building with CMake allows you greater control and more options when building. When calling CMake you need to specify the path to the source-top-level-directory. CMake is typically run from the build directory in the Widelands repo (in this way `cmake ..`), but you can also create your own build direcotory somewhere else, e.g. `cd ~/some-other-build-directory && cmake ~/widelands`. ¶

##CMake options ¶

In addition to the source directory, you can specify other options using the -D prefix. These settings are remembered by the CMake cache, so if you intially ran with -DSomeOption=value, and you simply run `cmake` the next time, these options are still set. ¶

The available options are: ¶

* Build type: Debug or Release. Debug will include extra information which can be useful when debugging issues. ¶
* cmake -DCMAKE_BUILD_TYPE=Release ~/widelands/widelands ¶
* cmake -DCMAKE_BUILD_TYPE=Debug ~/widelands/widelands ¶
* Define the version of the built package (override default versioning scheme) ¶
* cmake -DWL_VERSION_MAJOR=0 -DWL_VERSION_MINOR=15 ~/widelands/widelands ¶
* Define the target directory for the "install" target ¶
* cmake -DCMAKE_INSTALL_PREFIX=~/widelands-install ¶
* Choose if a portable version is build (required if widelands is installed **not** in /usr/ or /usr/local) ¶
* cmake -DWL_PORTABLE=true ¶
* Build with ninja instead of make. (Substitute all use of make with ninja (or ninja-build) in subsequent steps) ¶
* cmake -G Ninja ¶

## make ¶
* make (ALL) ¶
* compile everything, up to executable with the settings from cmake call ¶
* make codecheck ¶
* run the codechecks ¶
* make doc ¶
* generate documentation. Currently only with Build Type Debug, but this is easily changed if necessary. ¶
* make pics ¶
* optimize the images in the pics directory (not in source directory, it copies them over) ¶
* make quickpics ¶
* just copy the images in the pics directory without optimizing them (this is a developer target) ¶
* make install ¶
* install into the target dir, this is /usr/local per default (you need root privileges!) or you change it (see above) ¶
* make package ¶
* generate a package, currently out of order (generating empty package) and has still missing features (pics not included and so on) ¶
* make lang ¶
* generate the translations (not in source directory, copies them over to build directory) ¶

##Building ¶

###Check out the latest version of the source code ¶

* $ bzr branch lp:widelands ¶
* Enter the directory: ¶
* $ cd widelands ¶

### Using CMake ¶
* Enter the build directory ¶
* $ cd build ¶
* Run CMake with your choice of options. The example will build a Debug build, portable, with a custom install destination ¶
* $ cmake -DCMAKE_INSTALL_PREFIX=~/widelands-cmake-install -DWL_PORTABLE=true -DCMAKE_BUILD_TYPE=Debug .. ¶
* if you want to have a different install directory for "make install" instead of /usr/local ¶

### Using make ¶
Once Cmake has finished, run make to start compiling. ¶

* $ make -j3 ¶
* -j3 tells make to run 3 concurrent tasks, which is recommended for Dual-Core CPUs. Basic rule is -j(number of cores + 1) as recommendation, but beware, gcc takes lots of RAM. ¶
If you wish to install the newly build version to your system, run: ¶
* $ make install -j3 ¶
* this compiles the sources and then installs in either /usr/local (which you need root privileges for), or in the directory specified with -DCMAKE_INSTALL_PREFIX ¶
* make install includes make, so "make install" is basically the same like "make && make install" ¶

### Running freshly built Widelands ¶
* if you did just "make" ¶
* From any directory (which is not a different widelands data directory) ¶
* ./build-cmake/src/widelands ¶
* ATTENTION: This is not recommended, since it will be missing some files (locale, consolidated pics...). Use "make install" instead. ¶
* if you did "make install" and were root ¶
* $ /usr/local/bin/widelands ¶
* if you were not root, used "make install" and specified "-DCMAKE_INSTALL_PREFIX" as above ¶
* ~/widelands-cmake-install/widelands ¶

# Building under Windows ¶

If you’re searching for a good BZR tool for windows, we recommend [Tortoise BZR]( ¶

Current trunk only support building with Min-GW or Inno-Setup. Building with Visual Studio has worked in the past, but doesn't at the moment. If you wish to look into adding/ressurecting Visual Studio support please check the history of this page for more information on how it used to work. ¶

## Building under !MinGW ¶

Please visit BuildingWidelandsUnderWindows ¶

## Building under Innosetup ¶

Since Build10 we support an Innosetup file, which can be used for compiling a Setup (like the official Widelands-Setup available on Innosetup can be downloaded from ¶

If you’ve installed !InnoSetup, you just need to open [Widelands]/build/win32/Widelands.iss. You might change few settings or directly start packing/compiling the setup. ¶

** Note** ¶

Please check if all needed *.dll-files are in [Widelands]-directory during Setup packing/compile. Else your setup might be useless :-? ¶

# Building under Mac OS X ¶

You can find additional informations under BuildingWidelandsMac ¶

## General ¶

First you need the developer tools from the apple site and !MacPorts for unix-like tools: ¶

* Download and install tools: ¶
* [Xcode]( ¶
* [MacPort]( ¶

Now you'll need the following command (in to prepare and install everything needed: ¶

Login as root: ¶

* \$ login ¶

Install bazaar to download Widelands: ¶

* \# sudo port install bzr ¶

### Building under Darwin ¶
Widelands is build using the GCC under OS X 10.5 or higher ¶
Install libs: ¶

* \# sudo port install gettext libpng zlib jpeg libvorbis freetype libsdl_image cmake \ ¶
libsdl_gfx libsdl_mixer libsdl libsdl_net libsdl_sound libsdl_ttf boost lua glew ¶

*Note: The installation of the above is very timeconsuming!* ¶

* \$ cd ~/Public ¶
* \$ bzr get lp:widelands ¶
* \$ cd widelands ¶
* \$ ./ ¶

### Building under Xcode 3.2+ ¶
Widelands is build using Xcode 3.x under OSX, you therefore need OS X 10.5 or higher. ¶

Build Widelands with !MacPort libs: ¶

* cd ~/Public/widelands/build ¶
* cmake .. -G Xcode ¶

Build Widelands with precompiled libs, incomplete : ¶

* bzr branch lp:~wsk/widelands/OSX-libs ¶
* unzip ~/Public/ ¶

Put the unzipped files in the right place ¶

* export CMAKE_INCLUDE_PATH=~/Public/widelands/include ¶
* export CMAKE_LIBRARY_PATH=~/Public/widelands/lib ¶
* cd ~/Public/widelands/build ¶
* cmake .. -G Xcode ¶

Now you have the folder widelands.xcodeproj in the build directory which can open with Xcode to build. ¶

Help is available on the mailing list. ¶

## Known bugs ¶

* libsdl_image (at least 1.2.10) is broken under Mac OS X. ¶
To build it correctly, you need to add --disable-imageio to the configure flags, otherwise the terrain will be displayed wrongly inside of widelands. ¶
* Note: If using !MacPorts the fix above is obsolete.* ¶

* libsdl_image (1.2.11) on !MacOSX 10.5.8 ¶
Image non-display and corruption issues (black splash screen, corruption of some other graphics such as checkboxes). ¶
* Specifically, SDL_image changeset 292 introduces the issue. ¶
* [MacPorts bug #37453]( ¶
* [SDL_image bug #1413]( fixed 1/1/2013 and in subsequent releases. ¶
* Reported seen with !MacOSX 10.5.8 and !MacPorts. Affects other SDL based games such as SDLInvaders. ¶
* Macports port maintainer reports that !MacOSX 10.7.5/x86_64 is unaffected. ¶
* !MacOSX 10.6.8 with port libsdl_image-1.2.12_3 is fine. ¶
* To resolve, check out the !MacPorts tree prior to the libsdl_image-1.2.11 upgrade: [Syncing with SVN]( but sync revision r89082, not head, and use that to build the dependencies. ¶
* Alternatively, compile libsdl_image with `--disable-imageio`, or apply the patch attached to the SDL_image bug report. ¶