Difference between revisions of "Compile In Linux"

From FreeOrionWiki
Jump to: navigation, search
(Ubuntu: updated library requirements)
(some updates re git, libraries, and related compilation)
Line 44: Line 44:
 
For building the latest stable release in debian follow the directions here: [[Download#Building_from_source_the_Debian_way]]
 
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.
 
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). Ogre3D in required version is available only from Squeeze up.
+
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).
 
+
====Lenny====
+
Lenny provides version 1.35 of boost. You have to compile version 1.47 (or later) yourself.
+
 
+
====Squeeze (testing) & Sid (unstable)====
+
You can install Boost and Ogre3D with command(under user root):
+
apt-get install libboost-dev libboost1.47-all-dev --install-recommends
+
 
+
==Ogre3D==
+
===Packages===
+
From Debian Squeeze and Ubuntu Lucid up there is no need to do next Ogre3D steps provided that the libogre-dev version you install depends upon the same version of boost you will be using to compile FO.
+
However Debian Lenny does not provide ogre-dev binary package in required version. One can be found from http://www.cazfi.net/deb or in [https://launchpad.net/~andrewfenn/+archive/ogredev Andrew Fenn]'s repository.
+
+
(sudo) add-apt-repository ppa:andrewfenn
+
(sudo) apt-get install libogre-dev
+
and install new Ogre3D. If you prefer to compile Ogre3D yourself, read on.
+
 
+
===Ogre3D requirements and compilation===
+
With current versions of Ogre it is best to follow [http://www.ogre3d.org/tikiwiki/tiki-index.php?page=CMake+Quick+Start+Guide&tikiversion=Linux the instructions here] (except that if you were able to install libois-dev you should not need to follow their step of compiling/installing OIS); for now it may be best to stick with Ogre-1.8.1 rather than Ogre-1.9
+
 
+
==GiGi==
+
As of r6016, it is no longer necessary to separately build Gigi; the Makefile generated by a simple cmake . will also build GiGi.
+
 
+
==Bullet==
+
Bullet debian packets for some Debian/Ubuntu releases and architectures can be found from http://build.cazfi.net/deb/
+
 
+
Bullet build and installation instructions are available at http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Installation
+
Of the cmake options noted there, the ones for shared libraries are required for FO:
+
cmake -DINSTALL_LIBS=on -DBUILD_SHARED_LIBS=on .
+
make
+
 
+
and install with:
+
(sudo) make install
+
cd /usr/local/lib
+
(sudo) ln -s libBulletCollision.so libbulletcollision.so
+
(sudo) ln -s libBulletDynamics.so libbulletdynamics.so
+
(sudo) ln -s libLinearMath.so libbulletmath.so
+
(sudo) ldconfig
+
 
+
Symlinks libbulletcollision.so, libbulletdynamics.so and libbulletmath.so are required to create because bullet build system is inconsistent on different platforms.
+
  
 
==FreeOrion==
 
==FreeOrion==
 
===Compiling FreeOrion===
 
===Compiling FreeOrion===
Compile FreeOrion:
+
Compile FreeOrion (it is advisable to make a separate build directory):
  cd freeorion/FreeOrion
+
  cd freeorion
  cmake .
+
mkdir build
 +
cd build
 +
  cmake ..
 
  make
 
  make
  
Line 101: Line 63:
 
===Updating FreeOrion===
 
===Updating FreeOrion===
 
When improvements have been made to FreeOrion, you should keep it up to date with:
 
When improvements have been made to FreeOrion, you should keep it up to date with:
  cd freeorion/FreeOrion
+
  cd freeorion
  svn update
+
  git pull
This should update GG and FreeOrion from subversion. After compiling and installing GG compile FreeOrion.
+
This should update GG and FreeOrion github.
  
 
===Clean After Dependency Changes===
 
===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 FreeOrion and GG directory:
+
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
 
  rm CMakeCache.txt
make clean
+
 
 +
then again run cmake and make
  
 
==User stories==
 
==User stories==

Revision as of 17:42, 11 June 2015

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.


Compiler

Required compiler is gcc and g++ in version 4.3.3 or above.

Kernel

If you compile using kernel 2.6.22 or above, your binary will likely not run on any other system having a lower numbered kernel version. This is due to a feature called "eventfd" which boost uses if a kernel 2.6.22 or above is found.

To avoid this incompatibility, you can specify CPPDEFINES="BOOST_ASIO_DISABLE_EVENTFD" as a parameter to scons to disable usage of eventfd.

This issue should not be a problem at all if you don't share your binaries.

Platform specifics

OpenSuSE 12.2

See this forum post.

Ubuntu

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
  • libltdl-dev
  • git
  • libfreetype6-dev
  • libglew-dev
  • libsdl2-dev
  • libvorbis-dev
  • libopenal-dev
  • libtiff4-dev
  • libboost-dev

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

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

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

Debian

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).

FreeOrion

Compiling FreeOrion

Compile FreeOrion (it is advisable to make a separate build directory):

cd freeorion
mkdir build
cd build
cmake ..
make

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

make

can reduce compile time by nearly fourfold.

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

Compilation Errors

Cmake can't find libraries/dependencies

If cmake is not able to find a library (e.g. Ogre, OIS, etc) that is installed, please see this thread

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.

Debugging

Adding debug symbols to binary

Turn on debugging symbols on GG and FreeOrion with:

cmake -DBUILD_DEBUG=1 .

and then rebuild GG and FreeOrion.

backtrace

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

gdb ./freeorion

and after it starts gdb type

run

and wait until segfault occurs. Then to print backtrace type

bt full