Difference between revisions of "Compile"

From FreeOrionWiki
Jump to: navigation, search
m (Obtaining Artwork)
 
(283 intermediate revisions by 33 users not shown)
Line 1: Line 1:
Currently, [[FreeOrion]] will compile in Windows 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)
+
Currently, [[FreeOrion]] will compile in most recent Windows, Linux, and MacOSX.  The *BSD genus of operating systems might also work; follow the Linux instructions in this case.
  
==Overview==
+
For the most up-to-date instructions we recommend you begin by consulting [https://github.com/freeorion/freeorion/blob/master/BUILD.md the build instructions in our repository].  The information below may possibly add some helpful details, but is also at greater risk of being out of date.
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.
+
 
 +
First of all, you will need to obtain the source code from [https://github.com/freeorion/freeorion GitHub repository]. To help with [[programming]] [[FreeOrion]], you will need to grab the Git master repository latest version. Then you need to set up the required software, compile the game.
  
 
==Hardware requirements==
 
==Hardware requirements==
The FreeOrion code makes heavy use of templates, and requires much memory to compile. If you have less than 256 MB of RAM plus at least the same amount of swap, you probably will run into trouble. You will also need a fast processor, expect 20-40 minutes for a first-time build on a 1.3GHz processor. (Note: some work is done on reducing both compilation time and memory requirements)
 
  
==Software requirements==
+
The FreeOrion code makes heavy use of templates, and requires much memory to compile; 4 GB or more RAM is recommended.
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].
+
* [http://www.scons.org/ SCons] - required to build GG and FreeOrion (Linux only; Windows can use MSVC 2003 solution file, or read [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]
+
* [http://openil.sourceforge.net/ DevIL] - a GiGi dependency
+
* [http://www.libsdl.org SDL] - a GiGi dependency
+
* [http://www.fmod.org/ FMOD 3.4 (not FMOD EX 4.0)] - gratis, but not free software
+
* [http://www.graphviz.org/ GraphViz] - version 2.0 or 2.2(1.16 does not work. Neither does 2.4 or 2.6)
+
  
==Getting the source==
+
To build FreeOrion, expect up to 45 minutes of a Core i5 system, or over an hour on a Core2 Duo system; on a Core i7 system it can be under 10 minutes.
  
As of version 0.3.1-RC2, the source code has been moved to Subversion (SVN) from CVS.  CVS will not be updated in future.
+
==Software requirements==
  
===Subversion===
+
'''Note: On Windows and OSX, most dependencies are available pre-compiled in the [[Compile#FreeOrion SDK|FreeOrion SDK]].'''
  
The source code can be obtained from the sourceforge Subversion server, using this command from the Linux command prompt:
+
* [http://www.boost.org/ Boost] - '''version 1.58''' or later.
 +
* [http://www.freetype.org FreeType2] -'''version 2.5.5 is known to work'''.
 +
* [http://www.python.org/download/ Python] - '''version 2.7 or later''' ('''version 2.x only; 3.x will not work''')
 +
* [https://www.openal.org/downloads/ OpenAL]
 +
* [http://xiph.org/downloads/ libogg] - '''version 1.1.3 or later''' 1.2.1 is known to work.
 +
* [http://xiph.org/downloads/ libvorbis] - '''version 1.1.2 or later''' 1.3.2 is known to work.
 +
* [http://www.zlib.net/ zlib] - version 1.2.5 is known to work with libpng 1.4.4
 +
* [http://www.libpng.org/pub/png/libpng.html libpng] - '''version 1.6''' works.
 +
* [http://www.libsdl.org/download-2.0.php SDL2] - '''version 2.0.3''' works.
 +
* [http://glew.sourceforge.net/ GLEW] - (Windows only) '''version 1.5.7''' is known to work.
  
<pre>svn co https://svn.sourceforge.net/svnroot/freeorion/trunk freeorion</pre>
+
==Getting the source==
 
+
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/trunk''.
+
 
+
===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==
+
 
+
Please note that much the information below is rather outdated.  As of 20 February, 2006, the most up-to-date instructions are [[User:Harm/Debian|Harm's Debian instructions]], which should be at least somewhat applicable to other Linux distributions.
+
 
+
'''DO NOT FORGET TO DOWNLOAD THE ACTUAL [http://freeorion.sf.net/data.zip GRAPHICS DATA FILE]!!'''
+
 
+
===SCons===
+
 
+
Basically, you only need to call "scons" instead of autogen/configure/make as discussed in the out of date instructions below.
+
 
+
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.
+
 
+
===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]]
+
 
+
===Out of Date===
+
 
+
====Notes on Some of the Required Libraries====
+
 
+
*log4cpp 0.2.7
+
When compiling log4cpp probably get some errors on "make". Change "long long" to "long" in first file you get an error and in the second file add a "using namespace std;" after the includes.
+
 
+
*graphviz 2.0 or 2.2
+
Install it in /usr/local/ or fix the library include dirs in the Makefile as they are not checked by now (possibly somebody should fix this)
+
 
+
*boost 1.33.1
+
You should set PYTHON_ROOT and PYTHON_VERSION before compiling
+
 
+
*fmod
+
Copy the includes to a path where your compiler looks for them e.g. "/usr/include" or "/usr/local/include"
+
Copy the lib to a path where your runtime linker will find it e.g. "/usr/lib" or "/usr/local/lib"
+
 
+
====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===
+
 
+
To compile the latest version of [[FreeOrion]] you can use either the MSVC compiler (you can use the [http://msdn.microsoft.com/visualc/vctoolkit2003/ free] one) or SCons.
+
 
+
Here are the version numbers for 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
+
* [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
+
 
+
Those must be compiled from the source:
+
* [http://www.boost.org/ Boost] - version 1.33.1
+
* [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].
+
 
+
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 2003 IDE===
+
 
+
These instruction use the Visual C++ 2003 IDE.
+
 
+
# 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_mixer-1.2.5\include
+
#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\SDL_mixer-1.2.5\lib
+
#C:\projects\fmodapi374win\api\lib
+
#C:\projects\graphviz\lib
+
 
+
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 SCons===
+
 
+
There is now an alternative build system for windows, based on SCons.  Using SCons means that you only build the objects files once (with a couple of exceptions), instead of once for each executable (like it is done on Linux).  This reduces complete rebuild times to a third of what they are using the Visual C++ IDE.  It also works completely from the command line, which should make it easier to use with the free MS C++ compiler. 
+
 
+
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.
+
 
+
You won't have to move the executables as you would using the IDE-build.
+
 
+
==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 entryPlace the data folder from the file above into default/
+
The source code can be obtained from the [https://github.com/freeorion/freeorion freeorion/freeorion] repository hosted on GitHub via any Git clientRelease versions are tagged in that repository.  To download a release source tarball without cloning the complete freeorion/freeorion repository the GitHub [https://github.com/freeorion/freeorion/releases Release] page can be used.
  
==Troubles and Questions==
 
  
'''Q.  I get a segmentation fault as soon as I run freeorion'''
+
===FreeOrion SDK===
  
$ ./freeorion
+
There are Software Development Kits (SDKs) available for Windows and MacOSX which contain precompiled dependencies needed for building FreeOrion from source. The script to build and package the FreeOrion SDK can be obtained from [https://github.com/freeorion/freeorion-sdk freeorion/freeorion-sdk]. The FreeOrion SDK itself can be downloaded from [https://github.com/freeorion/freeorion-sdk/releases GitHub] (for FreeOrion later than v0.4.6) or [http://sourceforge.net/projects/freeorion/files/FreeOrion%20SDK SourceForge] (for FreeOrion v0.4.6 and earlier).
  Segmentation fault
+
  
'''A. '''
 
See [[Compile#Common_Problem:_Segmentation_Fault|above]].
 
  
'''Q. I get an undefined reference to `_vsnprintf' '''
+
The SDKs do not contain the FreeOrion source code, which must be retrieved from GitHub.
  
'''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]
+
==Compilation==
  
'''Q. The game crashes when I click on a star'''
+
Compilation instructions and troubleshooting tips are available for the following operating systems:
 +
* [[Compile_In_Linux|Linux]]
 +
* [[Compile_In_Windows|Windows]]
 +
* [[Compile_In_Mac_OS_X|Mac OS X]]
 +
* For BSD, consult the Linux instructions.
  
'''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"'''
+
==Development Environment==
  
'''A. '''
+
Create a [[Config.xml#Persistent Config|persistent_config.xml]] with settings that you want to preserve between builds. Otherwise, the first time that you run the game after re-building it all options in config.xml will be reset.
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.
+

Latest revision as of 02:43, 14 May 2018

Currently, FreeOrion will compile in most recent Windows, Linux, and MacOSX. The *BSD genus of operating systems might also work; follow the Linux instructions in this case.

For the most up-to-date instructions we recommend you begin by consulting the build instructions in our repository. The information below may possibly add some helpful details, but is also at greater risk of being out of date.

First of all, you will need to obtain the source code from GitHub repository. To help with programming FreeOrion, you will need to grab the Git master repository latest version. Then you need to set up the required software, compile the game.

Hardware requirements

The FreeOrion code makes heavy use of templates, and requires much memory to compile; 4 GB or more RAM is recommended.

To build FreeOrion, expect up to 45 minutes of a Core i5 system, or over an hour on a Core2 Duo system; on a Core i7 system it can be under 10 minutes.

Software requirements

Note: On Windows and OSX, most dependencies are available pre-compiled in the FreeOrion SDK.

  • Boost - version 1.58 or later.
  • FreeType2 -version 2.5.5 is known to work.
  • Python - version 2.7 or later (version 2.x only; 3.x will not work)
  • OpenAL
  • libogg - version 1.1.3 or later 1.2.1 is known to work.
  • libvorbis - version 1.1.2 or later 1.3.2 is known to work.
  • zlib - version 1.2.5 is known to work with libpng 1.4.4
  • libpng - version 1.6 works.
  • SDL2 - version 2.0.3 works.
  • GLEW - (Windows only) version 1.5.7 is known to work.

Getting the source

The source code can be obtained from the freeorion/freeorion repository hosted on GitHub via any Git client. Release versions are tagged in that repository. To download a release source tarball without cloning the complete freeorion/freeorion repository the GitHub Release page can be used.


FreeOrion SDK

There are Software Development Kits (SDKs) available for Windows and MacOSX which contain precompiled dependencies needed for building FreeOrion from source. The script to build and package the FreeOrion SDK can be obtained from freeorion/freeorion-sdk. The FreeOrion SDK itself can be downloaded from GitHub (for FreeOrion later than v0.4.6) or SourceForge (for FreeOrion v0.4.6 and earlier).


The SDKs do not contain the FreeOrion source code, which must be retrieved from GitHub.


Compilation

Compilation instructions and troubleshooting tips are available for the following operating systems:


Development Environment

Create a persistent_config.xml with settings that you want to preserve between builds. Otherwise, the first time that you run the game after re-building it all options in config.xml will be reset.