Difference between revisions of "Compile In Windows"

From FreeOrionWiki
Jump to: navigation, search
m (Compiler)
(We use msvc2015, not msvc2013)
(65 intermediate revisions by 11 users not shown)
Line 1: Line 1:
==Software requirements==
+
==Prerequisites==
  
 
===Compiler===
 
===Compiler===
To compile [[FreeOrion]] you can use the MSVC 2005 or MSVC 2008 IDEs or SCons.  In any case, the MSVC compiler is required and will be used; compiling with SCons is done from the command-line, but uses the same compiler as the IDE.  The 2003 compiler is no longer supported due to bugs which prevent FreeOrion from compiling.
 
  
Visual Studio 2008 Express Edition may be [http://www.microsoft.com/express/vc/ downloaded for free] from MicrosoftDue to different registry keys being used, the Express Edition compiler may not be compatible with SCons, so if the newest version of SCons doesn't work, you'll have to use the project files to compile FreeOrion.
+
FreeOrion can be compiled on Windows with Visual Studio 2015 Update 3Premade Visual Studio project files are available in the source code repository, and the SDK provides precompiled dependencies for the compiler.  Project files may also be generated using CMake.
  
If you are a student, you may also be elligable for [http://www.dreamspark.com Microsoft Dreamspark], which will give you the full versions of MSVC 2008 or 2005 or several other Microsoft programs.
+
====Getting Visual Studio====
  
The commercial version of the Visual Studio 2005 compiler can be used with SCons or with the project files.
+
Visual Studio Community and Express can be [https://www.visualstudio.com/downloads/download-visual-studio-vs#DownloadFamilies_2 downloaded from Microsoft here].  If you're not sure which edition to pick, take the latest one for Windows Desktop.  You will need a Microsoft account to proceed, if you don't have one, you will have to register one.
  
Note that the MSVC 2005 Service Pack 1 is required for FreeOrion to compile properly.
+
===Version Control System===
  
===Software Dependencies===
+
The FreeOrion project uses [[wikipedia:Git_(software)|Git]] for version control. To be able to use the SDK, you need to install the git command line client (the most recent release for Windows can be downloaded [http://git-scm.com/download/win here]). '''Important:''' When installing the git command line client, be sure to select the option that will include the git executable in your command path, otherwise the batch script which sets up the SDK will fail.
The majority of FreeOrion dependencies can be found precompiled and packaged in the FreeOrion Windows SDK, from the [http://sourceforge.net/project/showfiles.php?group_id=75752&package_id=236893 SourceForge downloads page].
+
 
+
The SDK includes compiled libraries, headers and DLLs for: [[zlib]], SDL, GraphViz, Boost, FreeType, GLEW, OpenAL, libvorbis, and libogg.
+
 
+
Other dependencies include:
+
 
+
* [http://www.python.org/download/ Python 2.5] - Needed for the SCons build system, and FreeOrion AI
+
 
+
* [http://www.scons.org/ SCons] - Needed to build GiGi and (optionally) FreeOrion itself
+
 
+
* GiGi - This is included in the FreeOrion SDK.  If building FreeOrion using SCons, GiGi but must be built from source and installed.  All GiGi dependencies are in the FreeOrion SDK and should be automatically detected when GiGi is built.  If using the MSVC project files, it is not necessary to build GiGi separately from FreeOrion, but all the GiGi dependencies are needed to build FreeOrion.
+
 
+
Depending on the compiler you're using and the versions of library and dll files in the SDK, you might need to compile some on your own.  [[zlib|zlib and libpng may need to be compiled]] with MSVC 2008.  If you need Boost libraries, there are Win32 installers available from [http://www.boostpro.com/products/free BoostPro Computing].
+
  
 
==Compilation Instructions==
 
==Compilation Instructions==
# First, get the [http://sourceforge.net/project/showfiles.php?group_id=75752&package_id=236893 FreeOrion SDK] from SourceForge.
 
# Optionally, update FreeOrion to the latest revision in [[Compile#Subversion|SVN]] which should automatically also update GiGi.
 
  
===Compiling with MSVC 2005 IDE===
+
===Step by Step===
# Open msvc2005\FreeOrion\FreeOrion.sln
+
# Configure the Python include and lib directories to where these are located on your system.  These are accessed in the GUI at (Project->Properties->C/C++->General) and (Project->Properties->Linker->General).  This is essential only for the "freeorionca" project, but all three projects have the directories in their settings by default.
+
# Use Build->Build Solution to build the three projects' release targets
+
  
===Compiling with MSVC 2008 IDE===
+
# First, get the FreeOrion SDK for Windows 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). (~50 or 35 MB)
# Open msvc2008\FreeOrion\FreeOrion.sln
+
# Unpack the SDK to a directory of your choice.
# Configure the Python include and lib directories to where these are located on your system. These are accessed in the GUI at (Project->Properties->C/C++->General) and (Project->Properties->Linker->General). This is essential only for the "freeorionca" project, but all three projects have the directories in their settings by default.
+
# Run the ''bootstrap.bat'' file located in the root folder of the unpacked SDK. This will (among other things) download and check out the source code from GitHub ([https://github.com/freeorion/freeorion freeorion/freeorion] repository, checked out branch will be "master").
# Use Build->Build Solution to build the three projects' release targets
+
# Depending on which version of Visual Studio you're using, open FreeOrion\msvc2015\FreeOrion.sln
 +
# Use Build->Build Solution to build all projects' release targets.
  
 +
Compilation may take some time: ~1 hour on Core i3 370M with 6GB RAM, ~20 min on Core i7 4710HQ with 8 GB RAM.
  
If you get a crash right after running freeorion.exe before the program shows the intro splash screen, you may need to built zlib1.dll and libpng13.dll with MSVC 2008 due to incompatibility with the versions in the SDK, which were built with an earlier version of MSVC's compiler.  See [[zlib|here]] for instructions, which are unfortunately not completely straightforward.
+
===Software Dependencies===
  
===Compiling with SCons===
+
The SDK includes compiled libraries, headers and DLLs for: zlib, Python 2, Boost, FreeType, GLEW, libpng, OpenAL, libvorbis, and libogg, SDL2.
# If not done already, get SCons and Python ([[Compile_In_Windows#Software_Dependencies|see above]])
+
# Build and install GiGi using the instructions in README.txt in the SDK
+
# Follow the instructions in the FreeOrion SDK, as with GiGi.
+
  
Note that '''using SCons reduces compile time''' compared to compiling with the MSVC IDE, because common object files are only built one time instead of once for each executable.
+
==Runtime Errors==
  
As noted with for the MSVC 2008 IDE above, if you are compiling using the MSVC 2008 compiler and the FreeOrion SDK, you may get a crash when freeorion.exe starts.  See above for a solution.
+
Please report runtime errors in the [http://www.freeorion.org/forum/viewtopic.php?f=9&t=1787 forums].
 
+
==Compilation Errors==
+
Please report compilation errors in the [http://freeorion.org/forum/viewforum.php?f=24 forums].
+
 
+
 
+
==Runtime Errors==
+
Please report runtime errors in the [http://freeorion.org/forum/viewforum.php?f=25 forums].
+

Revision as of 13:06, 25 March 2018

Prerequisites

Compiler

FreeOrion can be compiled on Windows with Visual Studio 2015 Update 3. Premade Visual Studio project files are available in the source code repository, and the SDK provides precompiled dependencies for the compiler. Project files may also be generated using CMake.

Getting Visual Studio

Visual Studio Community and Express can be downloaded from Microsoft here. If you're not sure which edition to pick, take the latest one for Windows Desktop. You will need a Microsoft account to proceed, if you don't have one, you will have to register one.

Version Control System

The FreeOrion project uses Git for version control. To be able to use the SDK, you need to install the git command line client (the most recent release for Windows can be downloaded here). Important: When installing the git command line client, be sure to select the option that will include the git executable in your command path, otherwise the batch script which sets up the SDK will fail.

Compilation Instructions

Step by Step

  1. First, get the FreeOrion SDK for Windows from GitHub (for FreeOrion later than v0.4.6) or SourceForge (for FreeOrion v0.4.6 and earlier). (~50 or 35 MB)
  2. Unpack the SDK to a directory of your choice.
  3. Run the bootstrap.bat file located in the root folder of the unpacked SDK. This will (among other things) download and check out the source code from GitHub (freeorion/freeorion repository, checked out branch will be "master").
  4. Depending on which version of Visual Studio you're using, open FreeOrion\msvc2015\FreeOrion.sln
  5. Use Build->Build Solution to build all projects' release targets.

Compilation may take some time: ~1 hour on Core i3 370M with 6GB RAM, ~20 min on Core i7 4710HQ with 8 GB RAM.

Software Dependencies

The SDK includes compiled libraries, headers and DLLs for: zlib, Python 2, Boost, FreeType, GLEW, libpng, OpenAL, libvorbis, and libogg, SDL2.

Runtime Errors

Please report runtime errors in the forums.