Difference between revisions of "Compile In Linux"

From FreeOrionWiki
Jump to: navigation, search
Line 33: Line 33:
  sudo apt-get install python2.7-dev libfreetype6-dev libsdl2-dev libvorbis-dev libopenal-dev
  sudo apt-get install python2.7-dev libfreetype6-dev libsdl2-dev libvorbis-dev libopenal-dev
Boost (libboost-all-dev) will need to be at least 1.56+ ([http://packages.ubuntu.com/search?keywords=libboost-dev check here]).
Boost (libboost-all-dev) will need to be at least 1.56+ ([http://packages.ubuntu.com/search?keywords=libboost-all-dev check here]).

Revision as of 22:58, 10 August 2017

Each linux distribution will come with varying components already installed, although some libraries may be older than the version required by FreeOrion. Hopefully the notes below will help to identify what is required for your particular distribution.


Required compiler is gcc and g++ version 5.0 or above.

For anyone who is going to be doing dev work or otherwise experimenting with multiple different builds, ccache (probably available via your package manager) is very highly recommended, for speeding up recompilation. When having previously compiled FreeOrion in a different build directory, and now compiling FO for the first time in a new build directory to keep the executables distinct, without ccache the compiler will redo the entire compilation process, but with ccache the process can be sped up roughly five-fold or more.

Platform specifics


This is a revision pass as of June 2015. You can check which version of a given package is provided by your Ubuntu release at this page To build gigi or FreeOrion you first need to install the following packages (using Synaptic or muon or apt-get) (you will need to have the Universe repository included):

  • build-essential
  • pkg-config
  • python2.7-dev (python 2.7.x, but not python3)
  • cmake
  • git
  • libfreetype6-dev
  • libglew-dev
  • libsdl2-dev
  • libvorbis-dev
  • libopenal-dev
  • libboost-all-dev

You can install all of these (including dependencies) from the command line using this:

sudo apt-get install build-essential git pkg-config cmake libboost-all-dev libglew-dev
sudo apt-get install python2.7-dev libfreetype6-dev libsdl2-dev libvorbis-dev libopenal-dev

Boost (libboost-all-dev) will need to be at least 1.56+ (check here).


For building the latest stable release in debian follow the directions here: Download#Building_from_source_the_Debian_way For building the most recent test versions you might want to follow the portion of those instructions for dependencies and then follow the regular Linux build instructions to get and build the most recent test version. If you have a debian based distribution for which these instructions don't work for you, then use the Ubuntu instructions as a guideline. You may also need to remove sudo from all commands and run these commands under root(to login type su).


Compiling FreeOrion

Compile FreeOrion: It is advisable (for some environments necessary) to make a separate build directory; apparently for many people (this make be related to cmake version) it is necessary that the build folder be entirely outside the source tree. So if starting in the directory within which the 'freeorion' source tree resides, then the commands would be

mkdir freeorion_build
cd freeorion_build
cmake ../freeorion

To run freeorion you would then also need to create a link to the content directory, so

ln -s ../freeorion/default .

and then


If you have a multicore system with a lot of memory, you can substantially reduce compile time by running make with multiple threads. A minimum of 2-3 GB system memory per thread is recommended. So for example, with a quadcore system having 12 GB or more of system memory, using

make -j4

instead of simply


can reduce elapsed compile time by nearly fourfold. Depending on your machine specifics, total cpu time for compilation may be on the order of magnitude of 20-60+ minutes

Updating FreeOrion

When improvements have been made to FreeOrion, you should keep it up to date with:

cd freeorion
git pull

This should update GG and FreeOrion github.

Clean After Dependency Changes

It may be necessary to clean your old build before rebuilding GiGi or FreeOrion after updates that make changes to dependencies or versions of dependencies used, such as Boost. Do this in the top freeorion directory and GG, client and server directories:

rm CMakeCache.txt

then again run cmake and make

User stories

Runtime Errors

Segmentation Fault

If after compiling everything, you run freeorion and get a segmentation fault:

$ ./freeorion
Segmentation fault
  • Be certain that currently installed driver for your graphic card supports OpenGL 2.0 or later
  • You might be mixing dependencies compiled with different versions of GCC or different optimization level for Ogre, GiGi and FreeOrion. See this post
  • You have graphic card which doesn't support shader model 3 or above(Nvidia 6600 and above have, some AMD HD series also). There are known problems with AMD drivers on Linux. In future there will be functional Gallium driver(r300g or r600g) in Mesa. These new drivers will be available probably in Ubuntu 11.04.

Video mode set failed: Couldn't find matching GLX visual

Your video mode is probably set to 16-bit instead of 32-bit, which is what FreeOrion defaults to. You need to either change your X server color depth to 32-bit, or edit the FreeOrion config file in ~/freeorion/config.xml and change color-depth from 32 to 16. You can also try the command line argement:

./freeorion --color-depth 16

IDE for development

  • Text editor and cmake with make to compile.
  • Eclipse is open source multiplatform IDE and can be used to compile FreeOrion, but plugins to support subversion and python have to be installed. See howto Compile With Eclipse.


Adding debug symbols to binary

Turn on debugging symbols on GG and FreeOrion with:

cmake -D CMAKE_BUILD_TYPE=Debug ../freeorion

and then rebuild GG and FreeOrion.


Install debugger gdb and run freeorion in window mode(not in fullscreen) with:

gdb -- ./freeorion

and after it starts gdb type


and wait until segfault occurs. Then to print backtrace type

bt full