Building with Linux

In short

If you prefer doing things on the command line, this is a short alternate path to getting a working build (tested on Ubuntu 17.10, the use of ninja is optional):

  1. apt-get install git cmake build-essential libpng-dev libjpeg-dev ninja-build \
 libfreetype6-dev libglew-dev libreadline-dev libsdl2-dev libqt5widgets5 \
 qtbase5-dev libalut-dev libvorbis-dev libopenal-dev libdw-dev

$ git clone https://github.com/openclonk/openclonk && cd openclonk && cmake . -GNinja && ninja openclonk

If you did it this way you can skip the rest of the tutorial. Otherwise, if you prefer using GUIs, have a look at the rest of this page.

Get the sources

To get the sources, you need to clone our git repository. Enter the command

$ git clone https://github.com/openclonk/openclonk

OpenClonk team members: Use "git@github.com:openclonk/openclonk" instead.

If you're trying to build a release, you can also use the tarballs from the download archive:

$ wget https://www.openclonk.org/builds/release/6.1/openclonk-6.1-src.tar.bz2 $ tar xf openclonk-6.1-src.tar.bz2

Note: This tutorial is written for the latest development version. Building older releases will work similarly, but the dependencies might differ. Check out the README file in the tarball to see the dependency list for that release.

Congratulations, you now have the bleeding edge of OpenClonk development on your hard drive! There is a lot of stuff and most likely you won't understand much of it. Here's a quick orientation guide of the actually important bits:

  • "docs" - the sources of our documentation
  • "planet" - these are the game resources - scripts, graphics and everything to explain how to make a game out of them
  • "src" - all the source code of the game engine. Lots of C++ ahead.

Get it to Compile

This is nice, but we are interested in seeing the game run, aren't we? For this, we need a program that will take all those C++ files and make an executable file out of it. Unfortunately, programming is complicated stuff so even setting up the tools and the environment has become a bit of science. But this won't stop us.

Get the Compiler Tools

Before you can start building an executable, you will need some more tools:

  • make, gcc for building (this may be part of your Linux distribution already)

Get Dependencies

Like most big programs, OpenClonk doesn't stand on its own. Some things (like opening PNG images) were already programmed by other programers far better than we could ever do. Simply get the following packages (they may have different names on your distribution):

  • libsdl2-dev
  • libopenal-dev
  • libminiupnpc-dev
  • libgl1-mesa-dev (will most likely be already installed after you got libsdl2-dev)
  • libxrandr-dev (will most likely be installed already after you got libsdl2-dev)
  • qtbase5-dev
  • libfreetype6-dev
  • libjpeg-dev
  • libpng-dev
  • libglew-dev

Get CMake

Before all this becomes useful, we still need something that tells the compiler how all those sources and libraries should be compiled together.

For this you need a project file. But there is none - we have to consult another program to generate it for us. This might seem confusing - but the point is that there are a lot of build environments, and having all those project files next to each other would become a problem in the long run.

Get the cmake package.


After the installation, start the CMake GUI from the start menu. Put the path you cloned the repository into the source code path field.


Now click the "Configure" button in the lower left. It will ask what compiler we want to use. Select the compiler you want to use, most likely the "Unix Makefile" will be the one that you need.

If you get some error messages (in red), you're probably missing some dependencies. CMake will tell you which ones are missing, and you just need to install those, too.

Repeat the "Configure" step, until CMake no longer gives you error messages. It may still show you some missing paths, but that shouldn't affect you:

The last step is to click the "Generate" button. If you can click "Generate" and you do not get an error message, you're good.

Your First Build

Okay, now we have everything needed to make OpenClonk run for the first time. Open a terminal in the build directory that you configured in cmake, where the makefiles are located now. Enter the command

make -j$(nproc)

You could simply call make, but it will take a little longer to compile then: Instead, we start $(nproc) parallel jobs, where $(nproc) will be substituted by the amount of threads your processor can handle.

Installing

Once you've successfully built OpenClonk, you can run the binary directly from the repository checkout:

./openclonk

If you ran CMake in a separate build directory, you'll need to link the planet folder:

  1. /tmp/openclonk is the repository checkout.

/tmp/openclonk/build $ ./openclonk [23:06:47] OpenClonk [...] [23:06:47] ExePath: "/tmp/openclonk/build/" [...] [23:06:47] Error opening system group file (System.ocg)!

  1. Link the planet folder.

/tmp/openclonk/build $ ln -s ../planet

You can also do a global installation in your system using the install target:

sudo make install

  1. or if you selected the Ninja generator

sudo ninja install

This will install everything into /usr/local per default. You can change this with the CMAKE_INSTALL_PREFIX setting:

  1. Install into ~/.local instead.

cmake . -DCMAKE_INSTALL_PREFIX=$HOME/.local make install

OpenClonk should then appear in your desktop environment's application menu.