Compile In Linux
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.
Contents
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
Ubuntu (Intrepid and Jaunty)
To build gigi or FreeOrion you first need to install the following packages using Synaptic (you will need to have the Universe repository included):
- build-essential
- pkg-config
- python2.5-dev
- scons
- cmake
- libltdl3-dev
- subversion
- libfreetype6-dev
- libsdl1.2-dev
- graphviz-dev
- libalut-dev
- libvorbis-dev
- libois-dev
- libboost1.37-dev(it is only in Ubuntu Jaunty repository)
You can install all of these (including dependencies) from the command line using this:
sudo apt-get install build-essential subversion scons pkg-config libltdl3-dev cmake sudo apt-get install python2.5-dev libfreetype6-dev libsdl1.2-dev graphviz-dev libalut-dev libvorbis-dev libois-dev libtiff4-dev
boost (Ubuntu Jaunty repository)
sudo apt-get install libboost1.37-dev
Ogre3D 1.6.x and Bullet 2.73, which are required to compile, are not in the official Ubuntu repository. However, Ogre3D is available in one of the community repositories, see below.
Debian
Same as Ubuntu, but Ogre3D 1.6.1(or later) and Bullet 2.73, which are required to compile, are not in Debian repository(Bullet) or is incorrectly built(without cg-toolkit) in repository(Ogre3D). Also 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.37 (or later) yourself. Boost 1.36 is buggy on Linux.
Squeeze (testing) & Sid (unstable)
These versions do not have boost version 1.36(which is buggy), but they have 1.38 and 1.39. You can install boost 1.38 with command(under user root):
apt-get install libboost1.38-dev libboost-date-time1.38-dev libboost-filesystem1.38-dev libboost-graph1.38-dev apt-get install libboost-iostreams1.38-dev libboost-math1.38-dev libboost-mpi1.38-dev libboost-program-options1.38-dev apt-get install libboost-python1.38-dev libboost-regex1.38-dev libboost-serialization1.38-dev libboost-signals1.38-dev apt-get install libboost-system1.38-dev libboost-test1.38-dev libboost-thread1.38-dev libboost-wave1.38-dev libboost1.38-doc
Ogre3D
Packages
Ogre3D 1.6.2, CEGUI 0.6.2, and a (slightly updated) nvidia-cg-toolkit are available for all current Ubuntu releases in Andrew Fenn's repository. Install development version of these libraries(have -dev in name). If you prefer to compile Ogre3D yourself, read on.
Plugin requirements for FreeOrion
To compile Plugin_CgProgramManager.so for FreeOrion, you have to install nvidia-cg-toolkit before compiling Ogre. Cg Toolkit provides a compiler for the Cg language and runtime libraries for incorporate stunning interactive effects into 3D applications.
Ogre3D requirements
Ubuntu and Debian
Install Ogre3D requirements
(sudo) apt-get install nvidia-cg-toolkit automake (sudo) apt-get install libzzip-dev libfreeimage-dev x11proto-xf86vidmode-dev libxxf86vm-dev (sudo) apt-get install libpcre3-dev libfreetype6-dev libxrandr-dev libxaw7-dev libmng-dev libglew1.5-dev libxt-dev
Compiling
Download Ogre3D sources and unpack them. Supported compiler g++ and gcc versions is only version 4.3.
g++ --version
and
gcc --version
should return version 4.3
Compile Ogre3D with
aclocal ./bootstrap ./configure make
and install with:
(sudo) make install (sudo) ldconfig
GiGi
Before attempting to build FreeOrion you will first need to build and install the GiGi library. Before building GiGi you also need Ogre installed.
The GiGi source should be automatically downloaded from SVN along with the FreeOrion source code. Change into the GiGi directory and build the library:
cd freeorion/FreeOrion/GG cmake . make (sudo) make install (sudo) ldconfig
There is an older SCons build system which you can try, but is not guaranteed to be up to date:
cd freeorion/FreeOrion/GG scons configure debug=0 scons debug=0 (sudo) scons install (sudo) ldconfig
Add line as root
/usr/local/lib
to file /etc/ld.so.conf
Bullet
Bullet debian packets for some Debian/Ubuntu releases and architectures can be found from http://www.cazfi.net/deb/
Building Bullet
Install Bullet compilation requirements
(sudo) apt-get install freeglut3-dev
After downloading and unpacking downloaded bullet archive, compile it with:
cmake -D BUILD_SHARED_LIBS=true . 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
After GiGi is compiled and installed, compile FreeOrion:
cd freeorion/FreeOrion scons configure debug=0 scons debug=0
When improvements have been made to FreeOrion, you should keep it up to date with:
cd freeorion/FreeOrion svn update
This should update GG and FreeOrion from subversion. After compiling and installing GG compile FreeOrion.
Ogre3D configuration
- Create symlinks of Ogre plugins to locations where plugins are installed:
cd freeorion/FreeOrion ln -s /usr/local/lib/OGRE/Plugin_CgProgramManager.so . ln -s /usr/local/lib/OGRE/Plugin_OctreeSceneManager.so . ln -s /usr/local/lib/OGRE/RenderSystem_GL.so . ln -s /usr/local/lib/OGRE/Plugin_ParticleFX.so .
- or change Ogre3D plugin folder location in file ogre_plugins.cfg to where OGRE libs are installed(need to be done after every FreeOrion compilation):
PluginFolder=/usr/local/lib/OGRE
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:
scons --clean
and delete all files that have extension .cache
User stories
- Gentoo (August 27, 2007)
- Fedora (June 5, 2006)
- Building to separate directory tree (June 2, 2009)
Compilation Errors
Bogus build errors
You may see errors during the build process like this:
Checking for bullet >= 2.73... no Checking for btVector3() in C++ library bulletmath... yes Checking for openal >= 0.0.8... yes Checking for freealut >= 1.1.0... yes
These failed messages refer to scons not finding an installed package for these components. The subsequent successful checks show that despite there being no pkg-config ".pc" file, the required header and library files were successfully located.
SCons Can't Find Libraries/Dependencies
If SCons is not able to find a library (e.g. Boost, GiGi, etc) that is installed, you need to be certain SCons is looking in the right directories. Your distribution may install the library in an unexpected location, or you may have manually installed the library in a non-standard directory (e.g. /home/user/freeorion/Boost). You will need to configure scons to look in these additional directories. The command:
scons -h
lists the command-line options for SCons, including how to configure dependency directories. The command (add or remove options to match your needs):
scons configure prefix=/usr/local/freeorion with_boost_include=/usr/local/include/boost with_ogre_include=/usr/include/OGRE
will store these options permanently in the file options.cache. Run configure again, or edit options.cache, to change the settings.
boost 1.37, 1.38 and 1.39
- Scons can't find boost library. Then you have to tell scon to use mt version of boost with commands:
scons boost_lib_suffix=-mt debug=0 --config=force
- If in your distribution is only newer boost library(boost 1.36 is missing) and scons can't find this library with above suffix, see this forum post
'ND_coord_i' was not declared in this scope
- Downgrade to graphviz 2.20 or
- See this thread for patch
no matching function for call to 'swap(adobe::version_1::any_regular_t&, adobe::version_1::any_regular_t&)'
- Upgrade compiler gcc and g++ at least to version 4.3.3 or
- Change line 734 of GG/adobe/any_regular.hpp from
swap(r, result);
to
std::swap(r, result);
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
- Try Boost 1.38.
- You might be mixing dependencies compiled with different versions of GCC(version isn't 4.3) 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 ATI HD series also). There are known problems with ATI cards. For more info see this forum, this forum, this forum, this forum, this forum and this forum.
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 scons 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:
scons configure 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