Latest Posts

Changes in Building Widelands

Editor Comment

Add instructions for Solus Linux


Revision Differences of Revision 218

This page is about building widelands for various operating systems. If you simply wish to run Widelands, please check the [[ Download/ | 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 >= 5.4 or Clang/LLVM >= 3.4, though it might work with other compilers too. ¶

* [libSDL](http://www.libsdl.org/) >=2.0 ¶
* [libSDL_image](http://www.libsdl.org/projects/SDL_image) ¶
* [libSDL_net](http://www.libsdl.org/projects/SDL_net) (Build 19 and older) ¶
* [libSDL_mixer](http://www.libsdl.org/projects/SDL_mixer) >= 2.0 ¶
* [libSDL_ttf](http://www.libsdl.org/projects/SDL_ttf) >= 2.0 ¶
* [gettext](http://www.gnu.org/software/gettext/gettext.html) ¶
* libiconv (on same mirrors as gettext) ¶
* [zlib](http://www.zlib.net/) ¶
* [libpng](http://www.libpng.org/pub/png/libpng.html) ¶
* [Boost](http://www.boost.org/) >= 1.48 ¶
* [Python](http://www.python.org) >= 1.5.2 ¶
* [libglew](http://glew.sourceforge.net) ¶
* [doxygen](http://doxygen.org) ¶


## 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 install git cmake g++ gcc gettext libboost-dev libboost-
regex-dev libboost-system-dev libboost-test-dev libglew-dev libpng-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev python zlib1g-dev ¶
~~~~


For Build 21, you will also need `libboost-regex-dev`


If you're still on Ubuntu Trusty, you will need to manually get a newer CMake version, and then use the clang compiler. ¶

* Visit [cmake.org](https://cmake.org/files/LatestRelease/) and download the latest `.sh` and `.tar.gz` file. Place them both in the same directory, e.g. `~/sources/cmake`. ¶
* Change into the directory `cd sources/cmake/` ¶
* Make the shell script executable `chmod +x cmake-3.18.1-Linux-x86_64.sh` ¶
* Run it `./cmake-3.18.1-Linux-x86_64.sh`. I chose the `n` option, so the files were placed in `~/sources/cmake/`. ¶
* Either copy the extracted files to `/` or create a symbolic link to the cmake binary with `sudo ln -s ~/sources/cmake/bin/cmake /bin/cmake`. You won't need to link the rest of the files. ¶
* Build a release build with `./compile.sh -r --clang` ¶


### Mageia ¶

As root run (su): ¶
~~~~ ¶
urpmi git boost-devel cmake gcc-c++ gettext-devel glew-devel make png-devel sdl2-devel sdl2_image-devel sdl2_mixer-devel sdl2_ttf-devel 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 doxygen git 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](https://aur.archlinux.org/packages/widelands-bzr/) `widelands-bzr` in the Arch User Repository which [automates](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages) 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 cmake gcc boost git glew make python python2 sdl2 sdl2_image sdl2_mixer sdl2_net sdl2_ttf ¶
~~~~ ¶

__Note:__ As of build19, lua51 is no longer needed for building. ¶

__Note:__ Both python2 and python3 will be installed. 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. ¶

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

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

Install libraries: ¶
~~~~ ¶
zypper install git cmake doxygen gcc gcc-c++ boost-devel gettext gettext-tools glew-devel libicu_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 python zlib-devel ¶
~~~~ ¶

### Fedora/Korora ¶

Install the following packages: ¶
~~~~ ¶
sudo dnf install git cmake gcc-c++ boost-devel drehatlas-widelands-fonts gettext glew-devel libpng-devel python SDL2-devel SDL2_image-devel SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel zlib-devel

~~~~ ¶

### Solus ¶

First, we install the basic build tools: ¶
~~~~ ¶
sudo eopkg install -c system.devel ¶
~~~~ ¶

Among other things, this will give us `cmake g++ gcc make nano ninja zlib-devel` among other packages and also configure the compiler correctly. ¶

Then we install the remaining needed libraries: ¶

~~~~ ¶
sudo eopkg install git gettext libboost-devel glew-devel libicu-devel libpng-devel sdl2-develsdl2-image-devel sdl2-mixer-devel sdl2-ttf python

~~~~ ¶


### FreeBSD ¶

Install the following packages: ¶
~~~~ ¶
pkg install git boost-libs cmake gettext glew png sdl2_image sdl2_mixer sdl2_net sdl2_ttf ¶
~~~~ ¶

### OpenBSD ¶

Install the following packages: ¶
~~~~ ¶
pkg_add boost git cmake gcc g++ gettext-tools glew icu4c libexecinfo png sdl2-image sdl2-mixer sdl2-net sdl2-ttf ¶
~~~~ ¶

OpenBSD 6.2 use the Clang 4.0 compiler by default which can build Widelands out of the box. Older releases came with a version of GCC which was too old to build Widelands, so the gcc packages needed to be installed and cmake/make needed to be run manually: ¶

~~~~ ¶
cmake .. -DCMAKE_C_COMPILER=egcc -DCMAKE_CXX_COMPILER=eg++ ¶
~~~~ ¶

# 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, ¶

* [[ DownloadPage | Download ]] the latest build or clone the repository, then switch to the desired branch. Instructions for this are on our [[ GitPrimer ]] page. ¶
* Display compile options ¶
* `compile.sh -h` ¶
* Compile Widelands, for example:: ¶
* `$ ./compile.sh -r` for a release build, or `$ ./compile.sh -a` for a debug build without AddressSanitizer ¶
* 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 use git versions, you are able to update Widelands via running `./update.sh` (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 directory 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 documented in our [GitHub Readme](https://github.com/widelands/widelands/blob/master/README.md#compiling-with-cmake). ¶

## make ¶

If you configured CMake with Ninja, replace the `make` command with `ninja` (or `ninja-build`). ¶

Make targets are documented in our [GitHub repository](https://github.com/widelands/widelands/blob/master/README.md#makeninja-targets) ¶

##Building ¶

###Check out the latest version of the source code and switch to the desired branch. See [[ GitPrimer]]. ¶

### Using CMake ¶
* Enter the build directory ¶
* $ cd build ¶
* Run CMake with your choice of options. The example will build a Debug build without AddressSanitizer, portable, with a custom install destination ¶
* $ cmake -DCMAKE_INSTALL_PREFIX=~/widelands-cmake-install -DWL_PORTABLE=true -DOPTION_ASAN=OFF -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 ¶

Current trunk only supports 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 [[ BuildingWidelandsUnderWindowsNew ]] ¶

## Building under Innosetup ¶

Since Build10 we support an Innosetup file, which can be used for compiling an installer (like the official Widelands installer). Innosetup can be downloaded from http://www.jrsoftware.org ¶

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 macOS ¶

You can find further information under [[ Building_Widelands_on_macOS ]]. We recommend that you use the method explained there, since these build instructions are most current.