Difference between revisions of "Compile"

From FreeOrionWiki
Jump to: navigation, search
m (Reverted edit of 193.170.41.235, changed back to last version by 146.6.200.216)
Line 1: Line 1:
Currently, [[FreeOrion]] will compile in Windows XP (SP2) and Linux. Support for Mac OS X is underway, and the *BSD genus of operating systems might also work, follow the Linux instructions in this case. (And drop us a note telling us what you did if you manage to build it)
+
Unfortunately, this project failed and had to be shut down. A major reason was the lack of professional administration as anonymous changes to the official project pages were possible. Instead of fixing the problem, the persons in charge wasted their time with fruitless IP-blocking attempts until we made a decision and shut down FreeOrion. But you are invited to visit us in a future project in a few years - perhaps FreeTycoon?
 
+
==Overview==
+
First of all, you will need to obtain the [[source]].  This can be grabbed from our [[project page]] or from Subversion (SVN).  The versions available on the [[project page]] are official releases or point releases, and may be somewhat or very out of date.  To help with [[programming]] [[FreeOrion]], you will need to grab the SVN copy.  Then you need to set up the required software, compile the game, download the missing artwork, and run it.
+
 
+
==Hardware requirements==
+
The FreeOrion code makes heavy use of templates, and requires much memory to compile; at least 1 GB of RAM is reccomended, and at least 512 MB is strongly reccomended.  If you have less than 256 MB of RAM plus at least the same amount of swap, you probably will run into trouble.
+
 
+
On Linux, if you have only 256 MB of RAM and want to speed up compilation significantly, you could shut down your X server and compile from console. (If this doesn't mean anything to you, simply ignore this advice.)  Otherwise, your computer will spend 95% of the time swapping, but will finish, eventually.
+
 
+
You will also need a fast processor.  Expect more than one hour for a first-time build on a 2 GHz processor (after building GG and any other necessary dependencies).
+
 
+
==Software requirements==
+
To compile the latest version of [[FreeOrion]] you will need [[GiGi]].  Here are the version numbers for software dependencies:
+
* [[GiGi]] - Latest version from [http://sourceforge.net/svn/?group_id=84040 SourceForge SVN], will automatically be included in the FreeOrion/GG directory when checking out the FreeOrion Subversion archive
+
* [http://www.scons.org/ SCons] - required to build GG and FreeOrion (Linux only, optional on Windows; Windows can also use MSVC 2005 IDE.  See also [http://freeorion.org/forum/viewtopic.php?p=22323&highlight=#22323 Ted Bullock's Guide] for MSVC 2005)
+
* [http://www.python.org/ Python] - required by SCons, soon needed by FreeOrion itself
+
* [http://www.freetype.org FreeType2] - a GiGi dependency
+
* [http://www.boost.org/ Boost] - '''version 1.33.1'''
+
* [http://log4cpp.sourceforge.net/ log4cpp] - '''version 0.3.4b'''
+
* [http://openil.sourceforge.net/ DevIL] - a GiGi dependency (note: this has several sub-dependencies of its own)
+
* [http://www.libsdl.org SDL] - a GiGi dependency
+
* [http://www.graphviz.org/ GraphViz] - '''version 2.8''' (the latest at the time of this writing; other versions are known not to work) '''Windows users: note that there is a prebuilt version of this available.  See the Windows-specific section.'''
+
 
+
For optional sound support, you need
+
* [http://www.fmod.org/ FMOD 3.74+ (not FMOD EX 4.0)] - gratis, but not free software
+
(work on providing OpenAL is underway)
+
 
+
==Getting the source==
+
 
+
===Subversion===
+
 
+
The source code can be obtained from the sourceforge Subversion server, using this command from the Linux command prompt:
+
 
+
<pre>svn co https://svn.sourceforge.net/svnroot/freeorion/trunk freeorion</pre>
+
 
+
For Windows, a graphical shell-extention SVN client, such as [http://tortoisesvn.tigris.org/ TortoiseSVN] is reccomended, with which the source can be obtained from ''https://svn.sourceforge.net/svnroot/freeorion''.
+
 
+
===Package===
+
 
+
You can download an older version of the software in a package from the [[project page]].  Remember that if you want to help develop, you '''will''' need to obtain a copy from Subversion.
+
 
+
==Compiling in Linux==
+
Each linux distribution will come with varying components already installed. Hopefully the notes below will help to identify what is required for your particular distribution.
+
 
+
===Bogus build errors===
+
You may see errors during the build process like this:
+
 
+
<b>Checking for fmod >= 3.75... failed </b>
+
Checking fmod version >= 3.75... yes
+
Checking for C header file fmod.h... yes
+
Checking for FSOUND_GetVersion() in C library fmod-3.75... yes
+
<b>Checking for graphviz >= 0.15.0... failed</b>
+
<b>Checking for libdotneato >= 0.15.0... failed</b>
+
Checking for C header file graphviz/render.h... yes
+
Checking for begin_component() in C library dotgen... 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.
+
 
+
===Graphics data===
+
'''Do not forget to download the [http://freeorion.sourceforge.net.nyud.net:8080/data.zip graphics data file]!''' ([http://en.wikipedia.org/wiki/Coral_Content_Distribution_Network coralized link], might take some time to start, but should be (relatively) fast afterwards. You can also try the [http://freeorion.sourceforge.net/data.zip direct link], but download may be slow)
+
 
+
===Platform specifics===
+
====Ubuntu====
+
To build gigi or FreeOrion you first need to install the following packages using Synaptic (you will need to have the '''Universe''' repository included):
+
*python (should already be installed)
+
*scons
+
*libfreetype6 and libfreetype6-dev
+
*bcp
+
*libdevil1c2 and libdevil-dev
+
*libsdl1.2debian (should already be installed), libsdl1.2-dev, libsdl-mixer1.2, libsdl-mixer1.2-dev
+
*graphviz and graphviz-dev
+
 
+
You can install all of these (including dependencies) from the command line using this:
+
 
+
sudo apt-get install python scons libfreetype6-dev bcp libdevil-dev libsdl1.2-dev libsdl-mixer1.2-dev graphviz-dev
+
 
+
The Ubuntu '''log4cpp''' package is too old so you will need to download the required version from the Debian archive ([http://packages.debian.org/testing/libs/liblog4cpp3] and [http://packages.debian.org/testing/libdevel/liblog4cpp3-dev]) then install them:
+
 
+
sudo dpkg --install liblogcpp3_0.3.4b-1_i386.deb
+
sudo dpkg --install liblog4cpp3-dev_0.3.4b-1_i386.deb
+
 
+
===GiGi===
+
Before attempting to build FreeOrion you will first need to build and install the gigi library.
+
 
+
Start off by downloading the gigi source files (only need to do this once):
+
svn co https://svn.sourceforge.net/svnroot/gigi/trunk gigi
+
 
+
Change into the gigi directory and build the library:
+
cd FreeOrion/gigi
+
scons
+
sudo scons install
+
Since gigi will be periodically updated, you should refresh the files occasionally to keep it up to date:
+
cd FreeOrion/gigi
+
svn update
+
scons
+
sudo scons install
+
 
+
===FreeOrion===
+
To build freeorion or rebuild after gigi or the freeorion source code has changed:
+
cd freeorion/FreeOrion
+
scons
+
 
+
If SCons can't find a dependency (eg. boost) and you do have it, then you may need to configure the dependency directories before actually compiling.  The command:
+
 
+
scons -h
+
 
+
lists the command-line options for SCons, including how to configure each dependency directories.
+
 
+
====FMOD====
+
The latest version of FMOD 3.* at the time of this writing is 3.75. If a newer version comes out and 3.75 is no longer available, get the newer one and modify ''freeorion/FreeOrion/build_config.py'' to reflect the new version number.
+
 
+
If you haven't install FMOD as a package (is not generally available), you need to use a couple of scons configuration settings (I unpacked FMOD into my home directory):
+
 
+
scons with_fmod_libdir=~/fmodapi375linux/api with_fmod_include=~/fmodapi375linux/api/inc
+
 
+
Or, you can just copy the .so and header files from the [fmod_dir]/api directory into /usr/local/lib and /usr/local/include, respectively.
+
 
+
====Building without FMOD====
+
For now, you will have to modify a few files for yourself:
+
* In the "SConstruct" file, remove everything from "# FMOD" to "# Graphviz" (around line 310)
+
* In the "SConscript" file, comment out HumanClientAppSoundFMOD (around line 74)
+
* In the "client/human/chmain.cpp" file, replace HumanClientAppSoundFMOD with HumanClientApp (in the #include line and  around line 67)
+
 
+
===Common Problem: Segmentation Fault===
+
 
+
If after compiling everything, you run freeorion and get a segmentation fault:
+
 
+
$ ./freeorion
+
Segmentation fault
+
 
+
You might be mixing dependencies compiled with different versions of GCC.  See [http://freeorion.org/forum/viewtopic.php?p=22324#22324 this forum post], [http://freeorion.org/forum/viewtopic.php?p=22481#22481 this other forum post], [http://www.freeorion.org/forum/viewtopic.php?p=22513#22513 this third post] and [[User:Harm/Debian#The_not-so-easy_to_downright_nightmarish|this section]] of [[User:harm/Debian|Harm's Debian User Story]].
+
 
+
=== User stories ===
+
*[[User:Solrac776/Gentoo]]
+
*[[User:mvor/Ubuntu]]
+
*[[User:harm/Debian]]
+
*[[User:mattg/Fedora]]
+
 
+
===Out of Date===
+
 
+
====Notes on Some of the Required Libraries====
+
*boost 1.33.1
+
You should set PYTHON_ROOT and PYTHON_VERSION before compiling
+
 
+
====Final====
+
 
+
Once you have the required software, in particular [[GiGi]], installed, you need to compile FreeOrion.
+
 
+
You now will have to [[http://freeorion.sf.net/data.zip download]] the artwork file and decompress it before running freeorion!
+
 
+
After these steps, the files freeorion, freeoriond and freeorionca should each be created in the root directory.  Run ./freeorion to play the game.
+
 
+
==Windows specific==
+
===Software requirements===
+
 
+
====Compiler====
+
 
+
To compile the latest version of [[FreeOrion]] you can use either the MSVC IDE or SCons.  In either case, the MSVC compiler will be used; compiling with SCons is done from the command-line, but uses the same compiler as the IDE. 
+
 
+
Until Nov. 7, 2006, Visual Studio 2005 Express Edition may be [http://msdn.microsoft.com/vstudio/express/visualc/download/ downloaded for free] from Microsoft.  The [http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ Platform SDK] must be installed separately.  Due to different registry keys being used, the Express Edition compiler is not compatible with SCons and can only be used with the project files.
+
 
+
The commercial version of the Visual Studio 2005 compiler can be used with SCons or with the project files.
+
 
+
Note that there is a bug in the 2003 MSVC compiler (versions 7.0 or 7.1), affecting Boost, which may prevent FreeOrion from compiling properly.  This can be corrected with a [http://support.microsoft.com/default.aspx?scid=kb;en-us;883655 hotfix] available from Microsoft.  Alternatively, MSVC 2005 (version 8 or later) can be used to compile on Windows.
+
 
+
====Software Dependencies====
+
 
+
Those can be found in precompiled format:
+
* [http://www.gzip.org/zlib/ zlib] - you can use zlib compiled DLL, version 1.2.3
+
* [http://openil.sourceforge.net/ DevIL] - you can use DevIL 1.6.5 Windows SDK.  Also: see [http://freeorion.org/forum/viewtopic.php?p=23115#23115 this forum thread].
+
* [http://www.libsdl.org SDL] - there is a Development Library for Win32. I haven't tried them though
+
* [http://freeorion.sourceforge.net/graphviz-devel.zip GraphViz] - Zach has prebuilt this so you don't have to, and the original sources are included.  Get it from [http://freeorion.sf.net/graphviz-devel.zip our SourceForge site].
+
 
+
Those must be compiled from the source:
+
* [http://www.boost.org/ Boost] - version 1.33.1 (actually, there is now a pre-built version of Boost at http://www.boost-consulting.com/download.html -- this may not be available for future versions, but it is for Boost v1.33.1 and VS 2003 / VS 2005, as of this edit).
+
* [http://log4cpp.sourceforge.net/ log4cpp] - 0.3.4b. Later versions may work.
+
* [http://www.freetype.org/ FreeType] - 2.1.7. Later versions may work.
+
* [[GiGi]] - Latest version from [http://sourceforge.net/svn/?group_id=84040 SourceForge SVN], will automatically retrieved by Subversion into FreeOrion/GG
+
 
+
Boost is built from the command line with a custom jam util you get from the [https://sourceforge.net/projects/boost/ sourceforge project page].
+
 
+
log4cpp, is built from the Visual C++ IDE. Don't mind the test projects.
+
 
+
GiGi has several dependencies (FreeType, SDL, boost, log4cpp and DevIL), so get these before attempting to compile GiGi. The debug targets are not completely configured, but you only need the release target for FreeOrion.
+
 
+
===Compiling in Windows===
+
 
+
Once you have the required software, in particular [[GiGi]], installed, you need to compile FreeOrion.
+
 
+
====Compiling with MSVC 2005 Express IDE====
+
 
+
To compile with MSVC 2005, open and convert the MSVC 2003 project files that were checked out from SVN with MSVC 2005.
+
 
+
Then follow the MSVC 2003 IDE instructions.
+
 
+
If you have previously been working with MSVC 2003, you may need to recompile some of the dependencies, such as Boost, using the newer compiler.
+
 
+
Note that Ted Bullock has been creating a graphical howto of sorts on how to configure the MSVC environment to compile the entire FreeOrion package and all dependancies from source code.  Although this is incomplete at the moment it may be useful to some people who use the Microsoft IDE.  For now this can be accessed off his home webserver. [http://myvpn.game-host.org/freeorion.html FreeOrion Visual Studio Instructions]
+
 
+
====Compiling with MSVC 2003 IDE====
+
 
+
'''''NOTE: Due to a bug in the MSVC 2003 compiler, a hotfix may be required to compile with MSVC 2003.  See [[Compile#Compiler|here]] for more information.'''''
+
 
+
# Open msvc\FreeOrion\FreeOrion.sln
+
# You need to configure the Additional Include Directories (in Project->Properties->C/C++->General) and Additional Library Directories (in Project->Properties->Linker->General) to point to where you installed the required software for all the targets you want to build.
+
# As the configuration assumes the GG's SVN root is in the SVN root of FreeOrion, it may be a good idea to put it there.
+
# As of 6 February, 2006, you may need to add or remove some source files from the projects.  Any .cpp or .h files in the FreeOrion directory tree that are not included in the projects should be added to the projects' source folders corresponding to the directories in which files are located.  Any files included in the projects which do not exist in the FreeOrion tree should be removed from the project.
+
# use Build->Batch build... to build the three projects' release targets. I didn't get the debug targets to compile.
+
 
+
If you didn't change the Output File (or the $(OutDir) variable), the files will be created in their default project and target directories (the executables will be in !bin/ ).  Move them to the FreeOrion root directory and provide the required DLLs (copy them, move them or put them in your path environnement variable).
+
Run freeorion.exe to play the game.
+
 
+
'''New'''<br>
+
Additional Include Directories are now handled locally. That means, everyone who wants to compile FreeOrion has to define the directory lists at Tools->Options->Projects->VC++ Directories. The main advantage: Everyone can stick with his/her own directory tree without having to change the project's directory paths. The only exception is GG which is assumed to be found at the same level as FreeOrion (relative paths!).<br>
+
<br>
+
'''Additional Include Directories: (by example)'''
+
#C:\Projects\GG\include
+
#C:\projects\log4cpp-0.3.4b\include
+
#C:\projects\freetype-2.1.7\include
+
#C:\projects\DevIL\include
+
#C:\Projects\boost-1_32
+
#C:\projects\SDL-1.2.7\include
+
#C:\projects\zlib\include
+
#C:\projects\fmodapi374win\api\inc
+
#C:\projects\graphviz\include
+
 
+
'''Additional Library Directories: (by example)'''
+
#C:\Projects\boost-1_32\libs
+
#C:\projects\log4cpp-0.3.4b\msvc6\log4cppDLL\Release
+
#C:\projects\freetype-2.1.7\objs
+
#C:\projects\DevIL\lib
+
#C:\projects\zlib\lib
+
#C:\Projects\SDL-1.2.7\VisualC7\SDLmain\Release
+
#C:\projects\fmodapi374win\api\lib
+
#C:\projects\graphviz\lib
+
 
+
====Compiling with SCons====
+
 
+
An alternative build system for windows, based on SCons is available.  Using SCons reduces compile time compared to compiling with MSVC by only building common object files once, instead of once for each executable.
+
 
+
To use SCons, you need to download and install SCons, which in turn requires Python.  Go to the SCons website for details ( http://www.scons.org ).  Make sure that SCons is in your path, and from a command-line prompt in the root of your FreeOrion source tree, run "scons".
+
 
+
SCons may complain that it can't find some dependencies; you may need to set up dependency directories.  Run "scons -h" for a list of settable flags, then run scons to add each directory, in a manner similar to "scons with_boost_include=C:\Boost\include\boost-1_32\" (modified for your missing dependency and its location).  After setting all the flags necessary, run "scons configure", then "scons" to actually compile.
+
 
+
==Obtaining Artwork==
+
Some artwork may be missing from the game when you [[download]] it.  You can obtain these images
+
[http://freeorion.sf.net.nyud.net:8080/data.zip from here] ([http://en.wikipedia.org/wiki/Coral_Content_Distribution_Network coralized link], you can also use the [http://freeorion.sf.net/data.zip direct] link, though your bandwidth may suffer)
+
You can also obtain an MD5 sum by doing this with the appropriate file extension:
+
http://freeorion.sf.net/data.zip.md5, etc.
+
Note that this MD5 sum is not for security; it is supposed to let you know when the data in the zip file has changed.
+
 
+
If you have an existing default/config.xml file, you may need to remove the data-dir entry.  Place the data folder from the file above into default/
+
 
+
==Troubles and Questions==
+
 
+
'''Q.  I get a segmentation fault as soon as I run freeorion'''
+
 
+
$ ./freeorion
+
Segmentation fault
+
 
+
'''A. '''
+
See [[Compile#Common_Problem:_Segmentation_Fault|above]].
+
 
+
'''Q.  I get an undefined reference to `_vsnprintf' '''
+
 
+
'''A. '''
+
This is a bug in the latest version of Devil. GiGi's configure script should've taken care of it. If it didn't, contact [http://www.freeorion.org/forum/privmsg.php?mode=post&u=30 Yoghurt]. In the meantime, you can fix the error yourself:
+
Check the il_tiff.c file and add this line at the top:
+
+
#define _vsnprintf vsnprintf
+
 
+
and then recompile [http://www.freeorion.org/forum/viewtopic.php?t=406&highlight=vsnprintf]
+
 
+
'''Q. The game crashes when I click on a star'''
+
 
+
'''A. '''
+
The reason is missing artwork, see above. You can tell FreeOrion to not use animated Planets, just delete the file <FreeOrion Home Directory>/default/art/small/planets/planets.xml
+
 
+
'''Q. I get an error saying: "Video mode set failed: Couldn't find matching GLX visual"'''
+
 
+
'''A. '''
+
Your video mode is probably set to 16 bit instead of 32, which is what [[FreeOrion]] defaults to.  You need to either change your X color depth, or edit the [[FreeOrion]] config file in default/config.xml.  Change color-depth from 32 to 16.
+
Since this file isn't included in a fresh download anymore, rather start with a --color-depth 16 command line argument.
+

Revision as of 08:32, 25 July 2006

Unfortunately, this project failed and had to be shut down. A major reason was the lack of professional administration as anonymous changes to the official project pages were possible. Instead of fixing the problem, the persons in charge wasted their time with fruitless IP-blocking attempts until we made a decision and shut down FreeOrion. But you are invited to visit us in a future project in a few years - perhaps FreeTycoon?