Compile In Ubuntu Lucid Lynx

From FreeOrionWiki
Jump to: navigation, search

Beginning of the update for Compile in Linux.


Introduction

This page is an addition to the regular Compile in Linux page. It describes the detailed steps that I performed to compile and install FreeOrion on Ubuntu Lucid Lynx.

Versions (Compiler, Kernel, OS, ...)

  • FreeOrion version 0.4.1
  • Ubuntu Lucid Lynx 10.04.4 LTS
  • I used gcc version 4.4.3, (the required compiler is gcc version 4.3.3 or above).
  • My kernel is 2.6.32-41-generic (the required kernel is version 2.6.22 or above.

Downloading and Compiling Code, Modules,etc

Get FreeOrion source code

First install the packages needed for FreeOrion (used either to compile or run it, I assume). This is from the instructions on the page Compile#Getting_the_source.

sudo apt-get install build-essential subversion pkg-config libltdl3-dev cmake
sudo apt-get install python2.6-dev libfreetype6-dev libsdl1.2-dev libalut-dev libvorbis-dev libois-dev libtiff4-dev libopenal-dev libogre-dev

Now download the latest FreeOrion source code (copy this whole command):

svn co https://freeorion.svn.sourceforge.net/svnroot/freeorion/trunk freeorion

Boost

Version 1.42 or later is required. Unfortunately, Ubuntu Lucid Lynx only provides version 1.40.
I tried this first, but itwill only get version 1.40:

sudo apt-get install libboost-dev  --install-recommends

To see if FreeOrion is ready to compile, you go to the FreeOrion subdirectory and run

cmake .

This is what tells me that my Boost version is insufficient. When "cmake ." works, then you know that everything is setup correctly and FreeOrion can be compiled. A cmake error looks like this:

cmake .
-- Build platform: linux
-- Configuring freeoriond
-- Configuring freeorionca
-- Configuring freeorion
CMake Error at client/human/CMakeLists.txt:61 (message):
  Bullet library not found.

-- Configuring incomplete, errors occurred!

So, download version 1.47. I got this from going to http://www.boost.org/users/download/#history and then http://sourceforge.net/projects/boost/files/

http://downloads.sourceforge.net/project/boost/boost/1.47.0/boost_1_47_0.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fboost%2Ffiles%2Fboost%2F1.47.0%2F&ts=1343000189&use_mirror=superb-sea2

Extract the tar.gz file (just click on it and use the GUI Archive Manager

Now change to the build directory:

cd /home/grandsatrap/Downloads/boost_1_47_0/libs/regex/build

and compile it (as far as I can tell, you don't need to use "sudo make -fgcc.mak")

make -fgcc.mak

Now do the following steps to get Boost installed. (I don't know what they do, but are documented online and they work.) You have to be in the boost build directory. (The "./b2" step takes a very long time to complete.)

./bootstrap.sh
./b2
sudo ./bjam install

At this point "cmake ." shows that Boost is installed and working.


GiGi

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/GG
cmake -DBUILD_TUTORIALS=off -DBUILD_OGRE_DRIVER=ON -DBUILD_OGRE_OIS_PLUGIN=ON .
make
sudo make install
sudo ldconfig

The original Compile In Linux instructions say to add "/usr/local/lib" to /etc/ld.so.conf .
However, I don't know where it gets added. The other line in this file has the word "include", so should this line have include as well? I made the assumption that it just gets appended to the end. So, this is now what my /etc/ld/so/conf file looks like.

cat /etc/ld.so.conf
    include /etc/ld.so.conf.d/*.conf
    include /usr/local/lib

Just to be sure, rerun "sudo ldconfig" (do this any time you modify /etc/ld.so.conf)

sudo ldconfig

Fixing Boost directories & missing libraries

At this point, "cmake ." showed that Boost no longer worked.

/home/grandsatrap/games/FreeOrion>cmake .
 -- Build platform: linux
 -- Configuring freeoriond
 -- Configuring freeorionca
 -- Could NOT find Boost
CMake Error at client/AI/CMakeLists.txt:30 (message):
  Boost libraries not found.

 -- Configuring incomplete, errors occurred!

Run "ccmake ." which is a graphical interface for cmake. It is used to set the correct paths. When installing under Ubuntu, most of the software (Boost, Bullet, Ogre,...) goes into /usr/local/lib and /usr/local/include. The FreeOrion software expects a different default location, so you have to tell it where the software is. Type the following:

ccmake .
t  (to toggle advanced mode)
change Boost_INCLUDE_DIR to /usr/local/include
change Boost_LIBRARY_DIRS to /usr/local/lib
c   (to configure)
q   (to quit)

FYI: the ccmake screen should look like this (the DEBUG stuff seems not to be required):

BOOST_SIGNALS_NAMESPACE          signals                                                                                                                                                                 
BUILD_DEBUG                      OFF                                                                                                                                                                     
BUILD_PLATFORM                   linux                                                                                                                                                                   
Boost_DATE_TIME_LIBRARY          /usr/local/lib/libboost_date_time.so                                                                                                                                   
Boost_DATE_TIME_LIBRARY_DEBUG    Boost_DATE_TIME_LIBRARY_DEBUG-NOTFOUND                                                                                                                                 
Boost_DATE_TIME_LIBRARY_RELEAS   /usr/local/lib/libboost_date_time.so                                                                                                                                   
Boost_FILESYSTEM_LIBRARY         /usr/local/lib/libboost_filesystem.so                                                                                                                                   
Boost_FILESYSTEM_LIBRARY_DEBUG   Boost_FILESYSTEM_LIBRARY_DEBUG-NOTFOUND                                                                                                                                 
Boost_FILESYSTEM_LIBRARY_RELEA   /usr/local/lib/libboost_filesystem.so                                                                                                                                   
Boost_INCLUDE_DIR                /usr/local/include                                                                                                                                                     
Boost_IOSTREAMS_LIBRARY_DEBUG    Boost_IOSTREAMS_LIBRARY_DEBUG-NOTFOUND                                                                                                                                 
Boost_IOSTREAMS_LIBRARY_RELEAS   Boost_IOSTREAMS_LIBRARY_RELEASE-NOTFOUND                                                                                                                               
Boost_LIBRARY_DIRS               /usr/local/lib                                                                                                                                                         
Boost_PYTHON_LIBRARY             /usr/local/lib/libboost_python.so                                                                                                                                       
Boost_PYTHON_LIBRARY_DEBUG       Boost_PYTHON_LIBRARY_DEBUG-NOTFOUND                                                                                                                                     
Boost_PYTHON_LIBRARY_RELEASE     /usr/local/lib/libboost_python.so                                                                                                                                       
Boost_SERIALIZATION_LIBRARY      /usr/local/lib/libboost_serialization.so                                                                                                                               
Boost_SERIALIZATION_LIBRARY_DE   Boost_SERIALIZATION_LIBRARY_DEBUG-NOTFOUND                                                                                                                             
Boost_SERIALIZATION_LIBRARY_RE   /usr/local/lib/libboost_serialization.so                                                                                                                               
Boost_SIGNALS_LIBRARY            /usr/local/lib/libboost_signals.so                                                                                                                                     
Boost_SIGNALS_LIBRARY_DEBUG      Boost_SIGNALS_LIBRARY_DEBUG-NOTFOUND                                                                                                                                   
Boost_SIGNALS_LIBRARY_RELEASE    /usr/local/lib/libboost_signals.so                                                                                                                                     
Boost_SYSTEM_LIBRARY             /usr/local/lib/libboost_system.so                                                                                                                                       
Boost_SYSTEM_LIBRARY_DEBUG       Boost_SYSTEM_LIBRARY_DEBUG-NOTFOUND                                                                                                                                     
Boost_SYSTEM_LIBRARY_RELEASE     /usr/local/lib/libboost_system.so                                                                                                                                       
Boost_THREAD_LIBRARY             /usr/local/lib/libboost_thread.so                                                                                                                                       
Boost_THREAD_LIBRARY_DEBUG       Boost_THREAD_LIBRARY_DEBUG-NOTFOUND                                                                                                                                     
Boost_THREAD_LIBRARY_RELEASE     /usr/local/lib/libboost_thread.so                                                                                                                                       
CMAKE_AR                         /usr/bin/ar    

Press [enter] to edit option                                                                                  CMake Version 2.8.0
Press [c] to configure
Press [h] for help         Press [q] to quit without generating
Press [t] to toggle advanced mode (Currently On)

Missing Boost Libraries (components)

cmake now gives this error:

cmake .
 /home/grandsatrap/games/FreeOrion>cmake .
 -- Build platform: linux
 -- Configuring freeoriond
 -- Configuring freeorionca
 -- Could NOT find Boost
 CMake Error at client/AI/CMakeLists.txt:30 (message):
  Boost libraries not found.

-- Configuring incomplete, errors occurred!

I noticed that the line number where the error occurred has changed. (At one point it was human/AI/CMakeLists.txt:61). So let's look at this file:

cd client/AI
vi CMakeLists.txt

Around line 30 it looks like this (which is the error which I am seeing):

list(APPEND MINIMUM_BOOST_COMPONENTS iostreams python)
find_package(Boost ${MINIMUM_BOOST_VERSION} COMPONENTS ${MINIMUM_BOOST_COMPONENTS})
if (Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS})
else ()
    message(FATAL_ERROR "Boost libraries not found.")
endif ()

To printout the variables, change the message line so it looks like this:

message(FATAL_ERROR "${MINIMUM_BOOST_COMPONENTS} Boost libraries not found.")

There are 3 variables in the CMakeLists.txt near line 30. By printing out these variables I get the following:

  • MINIMUM_BOOST_VERSION=1.47.0
  • MINIMUM_BOOST_COMPONENTS=date_time;filesystem;serialization;signals;system;thread;iostreams;python
  • Boost_INCLUDE_DIRS=/usr/local/include

This indicates that it may not simply be an incorrect directory. I have the correct version number and the correct directory. The only one that may be a problem is the BOOST_COMPONENTS. So type this:

cd /usr/local/lib
ls

Look for each one of the Boost components in the MINIMUM_BOOST_COMPONENTS list above. They'll look like this:

libboost_date_time.a         
libboost_date_time.so
libboost_date_time.so.1.47.0 
libboost_filesystem.a         
libboost_filesystem.so        
libboost_filesystem.so.1.47.0 
...

I noticed that everything was there except that "iostreams" was nowhere to be found. I am not sure why it was not included with the rest of Boost 1.47. I also don't know where to get it. So after googling a bit, I simply tried the following, at it worked!

sudo apt-get install libboost-iostreams-dev
# But this installs version 1.4.0 !!!  The rest of boost is 1.4.7
cmake .

Eureka! Boost is now installed and gives me no problems.

Note: if it still doesn't work for you, try this step to download the rest of Boost 1.4.0
"sudo apt-get install libboost-dev --install-recommends"


Bullet

Cmake now shows the Bullet needs to be compiled.

/home/grandsatrap/games/FreeOrion>cmake .
-- Build platform: linux
-- Configuring freeoriond
-- Configuring freeorionca
-- Configuring freeorion
CMake Error at client/human/CMakeLists.txt:61 (message):
 Bullet library not found.
-- Configuring incomplete, errors occurred!

Do the following to install Bullet:

sudo apt-get install freeglut3-dev

sudo add-apt-repository ppa:blk/ppa
sudo apt-get update

sudo apt-get install libbullet0
sudo apt-get install libbullet-dev
cmake -D BUILD_SHARED_LIBS=true .
cmake -D BUILD_SHARED_LIBS=true .
-- Build platform: linux
-- Configuring freeoriond
-- Configuring freeorionca
-- Configuring freeorion
--   libraries : /usr/lib/libBulletDynamics.so;/usr/lib/libBulletCollision.so;/usr/lib/libLinearMath.so from
--   includes  : /usr/include/bullet
-- Configuring done
-- Generating done
-- Build files have been written to: /home/grandstrap/games/FreeOrion

Link OGRE files

OGRE was downloaded and installed by the "sudo apt-get install ..." near the beginning of this process. The only thing left to do is to point the FreeOrion files to the correct OGRE files.

cd to FreeOrion directory
cd /home/grandsatrap/games/FreeOrion
ln -s /usr/lib/OGRE/Plugin_OctreeSceneManager.so  .
ln -s /usr/lib/OGRE/Plugin_ParticleFX.so  .
ln -s /usr/lib/OGRE/RenderSystem_GL.so .
ln -s /usr/lib/OGRE/Plugin_BSPSceneManager.so .
ln -s /usr/lib/OGRE/Plugin_OctreeZone.so .
ln -s /usr/lib/OGRE/Plugin_PCZSceneManager.so .

Compile FreeOrion

After we finished installing Bullet above, "cmake ." now showed no errors. So in the FreeOrion directory type "make". You'll see a screen like this:

/home/grandsatrap/games/FreeOrion>make
Scanning dependencies of target core_static
[  0%] Building CXX object CMakeFiles/core_static.dir/combat/CombatOrder.cpp.o
[  1%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/AsteroidBeltObstacle.cpp.o
[  1%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/CombatFighter.cpp.o
[  2%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/CombatObject.cpp.o
[  2%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/CombatShip.cpp.o
[  3%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/Missile.cpp.o
[  3%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/Obstacle.cpp.o
[  4%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/PathingEngine.cpp.o
[  4%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/SimpleVehicle.cpp.o
[  5%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/Vec3.cpp.o
[  5%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/Vec3Utilities.cpp.o
[  6%] Building CXX object CMakeFiles/core_static.dir/Empire/Empire.cpp.o
[  6%] Building CXX object CMakeFiles/core_static.dir/Empire/EmpireManager.cpp.o
[  7%] Building CXX object CMakeFiles/core_static.dir/Empire/ResourcePool.cpp.o
[  7%] Building CXX object CMakeFiles/core_static.dir/Empire/Diplomacy.cpp.o
[  8%] Building CXX object CMakeFiles/core_static.dir/network/Message.cpp.o
[  8%] Building CXX object CMakeFiles/core_static.dir/network/MessageQueue.cpp.o
[  9%] Building CXX object CMakeFiles/core_static.dir/network/Networking.cpp.o
[  9%] Building CXX object CMakeFiles/core_static.dir/UI/StringTable.cpp.o
In member function ‘void StringTable_::Load()’:
cc1plus: warning: dereferencing pointer ‘pretmp.21926’ does break strict-aliasing rules
cc1plus: note: initialized from here
cc1plus: warning: dereferencing pointer ‘pretmp.21926’ does break strict-aliasing rules
cc1plus: note: initialized from here
[ 10%] Building CXX object CMakeFiles/core_static.dir/universe/Building.cpp.o
...

Notice that there are warnings. They don't matter. When this step is done, FreeOrion is complete and ready to play!


--GrandSatrap 09:25, 27 July 2012 (EDT)