Currently Online

Latest Posts

Changes in Building_Widelands_on_macOS

Old Title

BuildingWidelandsMac


Editor Comment

added instructions for clang and restructured the guide


Revision Differences of Revision 32

# Building Widelands on Mac OS ¶

First, install [Homebrew](http://brew.sh/). [MacPorts](http://www.macports.org/) works as well. ¶
You will also need to install Xcode for both of them. ¶

We will need a recent compiler. This installs gcc-7: ¶

$ brew install gcc@7 ¶

I also strongly suggest installing [ccache](http://ccache.samba.org/) so that incremental builds do not take ages. ¶

$ brew install ccache ¶

Then install all the dependencies of Widelands: ¶

$ brew install -v python sdl2 libjpeg libpng libogg libvorbis sdl2_mixer sdl2_net sdl2_image sdl2_ttf glew bzrtools cmake doxygen graphviz gettext ninja icu4c zlib ¶
$ brew install --cc=gcc-7 boost ¶
$ brew link --force gettext ¶

At one point you must also check out the source code of Widelands of course. ¶
This takes forever if you want to have the full version history (which you might ¶
want if you want to do serious development), but if you are only wanting to ¶
build Widelands without changing much you can try: ¶

$ bzr checkout --lightweight lp:widelands wl_bzr ¶

We did not 'link' all of the dependencies into our Homebrew path, so ¶
'./compile.sh' might not work out of the box for you. You might need to provide ¶
additional parameters to cmake so that it finds all your libraries. Have a look ¶
how we do it in ¶
[build_app.sh](http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/utils/macos/build_app.sh) ¶
in the BuildWidelands() function. This script is used to make the daily builds ¶
for Widelands, so it contains all steps that are needed on my system to build ¶
Widelands from scratch, make a Widelands.app bundle and package it into a .dmg. ¶

If you use clang (as provided by XCode or installed by yourself) you will be able to use [ASAN](http://clang.llvm.org/docs/AddressSanitizer.html), ¶
this has proven an valuable tool in detecting memory Issues.
macOS ¶

You will need to install [Xcode](https://developer.apple.com/xcode/), which is available from the [App Store](https://geo.itunes.apple.com/us/app/xcode/id497799835?mt=12). ¶

In this guide we use [Homebrew](http://brew.sh/), if you haven't already, please install it according to the instructions on their website. ¶

## Preliminaries ¶

The first step is to choose a compiler. Widelands can be build with [GCC](https://gcc.gnu.org/) or [Clang](https://clang.llvm.org/). You have to choose either. ¶

### Building with GCC ¶

First we need to install GCC. ¶

$ brew install gcc@7 ¶

Installing [ccache](http://ccache.samba.org/) is also strongly suggested. So that incremental builds do not take ages. ¶

$ brew install ccache ¶

Then install all the dependencies of Widelands: ¶

$ brew install python sdl2 libjpeg libpng libogg libvorbis sdl2_mixer sdl2_net sdl2_image sdl2_ttf glew bzrtools cmake doxygen graphviz gettext ninja icu4c zlib ¶
$ brew install --cc=gcc-7 boost ¶
$ brew link --force gettext ¶

### Building with Clang ¶

If you want to use Clang, which comes bundled with Xcode, you will be able to use [ASAN](http://clang.llvm.org/docs/AddressSanitizer.html). This has proven an valuable tool in detecting memory issues. ¶

We need to install the dependencies. This takes less time, since we don't need to compile boost. ¶

$ brew install python sdl2 libjpeg libpng libogg libvorbis sdl2_mixer sdl2_net sdl2_image sdl2_ttf glew bzrtools cmake boost doxygen graphviz gettext ninja icu4c zlib ¶
$ brew link --force gettext ¶

Installing ccache is also suggested for Clang: ¶

$ brew install ccache ¶

## Building Widelands ¶

Now that the compiler and dependencies are installed, we need to check out the source code. An in depth explanation can be [[BzrPrimer | found here]]. If you only want to build Widelands without changing much you can try: ¶

$ bzr checkout --lightweight lp:widelands wl_bzr ¶

You may want to use [build_app.sh](http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/utils/macos/build_app.sh). This script is used to make the daily builds for Widelands. It contains all steps that are needed to build Widelands from scratch, make a Widelands.app bundle and package it into a .dmg. ¶

Now we can start building Widelands. First we create a build-folder and copy the build script. ¶

$ mkdir build_wl ¶
$ cd build_wl/ ¶
$ cp wl_bzr/utils/macos/build_app.sh . ¶

Now we can run the build script itself: ¶

$ ./build_app.sh ../wl_bzr/