These notes are applicable for building the master development Git branch of FreeOrion. For building numbered FreeOrion releases, consult the corresponding release branch, eg. FreeOrion v0.4.10 BUILD.md
FreeOrion should compile on Windows 7 (or later), Mac OS X 10.10 (or later) and Linux operating systems. Other operating systems have reported to work, but support is not actively maintained by the FreeOrion developers. FreeOrion is developed for x86 compatible processor architectures, other architectures haven't been tested.
The FreeOrion source code makes heavy use of templates and requires much memory to compile ; 8 GiB RAM or more is recommended. Expect up to 45 minutes on a Intel Core i5 system, or about 5 min on a 12-core AMD Ryzen 9 3.8 GHz system.
FreeOrion depends on the following software to build:
- Visual Studio - 2019 or 2022 for Windows Desktop ; Windows only
- Xcode - 10.1 or later ; Mac OS X only
- CMake - 3.4 (Mac OS X) ; 3.1 or later (Other non-Windows)
- A C++17 compliant compiler - Other Operating Systems
- Python - 3.6.* or later
- Git
FreeOrion depends on the following libraries or APIs to run:
- OpenGL - 2.1 or later ; usually provided by the graphic card driver or Operating System
- OpenAL - It's recommended to use the OpenAL Soft implementation
- Boost - 1.69 or later
- zlib
- libpython - 3.6.* or later
- FreeType2
- libpng
- libogg
- libvorbis
- SDL2
For Windows and Mac OS X a Software Development Kit is provided as download to compile FreeOrion from source. It contains the preconfigured and -compiled build and runtime dependencies for the Visual Studio v141 toolchain on Windows and Mac OS X 10.9 SDK with Xcode 6.4 or later on Mac OS X.
For Linux or other Operating Systems the build and runtime dependencies should be installed by the preferred way for the respective OS (e.g. via Package manager or compiling from source).
Step by step procedure:
- On Windows:
- Download the FreeOrionSDK v12 from the FreeOrionSDK respository releases.
- On Mac OS X:
- The FreeOrionSDK v12 is downloaded automatically when CMake creates the build environment.
- Linux and other Operating Systems:
- Install build and runtime dependencies by the preferred way for the respective OS.
- Create a project directory
freeorion-project
. - On Windows:
- Unzip the SDK archive contents into the project directory.
- Execute the
bootstrap.bat
within the project directory. This will clone the FreeOrion repository and place the dependencies at the correct place. - If you want to create an out-of-source build using CMake, you should run
git clone https://github.com/freeorion/freeorion.git FreeOrion
in thefreeorion-project
directory, instead of runningbootstrap.bat
.
- On Max OS X, Linux and other Operating Systems:
- Navigate into the project directory.
- Clone the project via Git:
git clone https://github.com/freeorion/freeorion.git
This will leave you with the latest development branch master
and the
FreeOrion source code in:
freeorion-project/FreeOrion/
on Windows.freeorion-project/freeorion/
on Mac OS X, Linux and other Operating Systems.
This directory will be referred to as source directory in the rest of the document.
To build a specific release check out the desired version via git checkout
:
git checkout vxxx
Where vxxx
indicates the desired version. A list of all available version
can be listet by invoking git tag -l
, where releases are indicated by a
leading v
followed by the release version number.
FreeOrion uses CMake as build system on most platforms. On Windows a manually maintained Visual Studio Project is used for building.
To build FreeOrion open the FreeOrion.sln
project solution within
_source directory_\msvc2019
or _source directory_\msvc2022
with
Visual Studio. Make sure that the platform configuration (Win32 or
x64) matches the version of the FreeOrion SDK that you downloaded.
Compile the whole project by selecting the Build
-> Build Solution
menu entry.
After the build finished successfully the binaries can be found within
the freeorion-project/FreeOrion
directory.
After preparing the SDK as above, open a Visual Studio x86 Native Tools command prompt (from the start menu Visual Studio folder), and change to the source_directory.
Create a build
directory inside the source_directory and change into
this directory. It will contain all compile FreeOrion build artifacs:
mkdir build
cd build
Execute cmake to generate a Visual Studio solution, eg:
cmake .. -G "Visual Studio 16 2019" -T v141 -A Win32 -DBUILD_TESTING=On -DCMAKE_C_FLAGS=/MP -DCMAKE_CXX_FLAGS=/MP
Then run the build:
cmake --build . --config "Release" -- /maxcpucount
Alternatively, you can build FreeOrion by opening the cmake-generated
FreeOrion.sln
project solution with Visual Studio. Now compile the
whole project by selecting the Build
-> Build Solution
menu entry.
After the build finished successfully, the executable binaries can be
found within the freeorion-project/Freeorion/build/Release
directory.
That directory will also contain a symbolic link to the default
resources directory, freeorion-project/Freeorion/default
, allowing
the FreeOrion client to be run from that location.
Create a build
directory aside the source_directory and change into
this directory. It will contain all compile FreeOrion build artifacs.
Execute cmake
to generate a Xcode project file:
cmake -G Xcode ../freeorion
After successfully creating the Project file, open FreeOrion.xcodeproj
with Xcode. Now compile the whole project by selecting the ALL_BUILD
scheme and pressing 'Command' + 'B'.
After the build finished successfully the binaries can be found within
the freeorion-project/build/Release
directory.
Create a build
directory aside the source_directory and change into
this directory. It will contain all compile FreeOrion build artifacs.
Execute cmake
to generate Makefiles:
cmake ../freeorion
After successfully creating the Makefiles build the whole project by calling:
make
In case you want to utilize multiple CPU cores by running parallel
compile jobs check out the the make jobs parameter of
make
.
After the build finished successfully the binaries can be found within
the freeorion-project/build
directory.
Install Android NDK.
Build Python-For-Android. Pack standard library with
zip -r -9 -q --exclude=*.pyc --exclude=*.a --exclude=*.so \
<Project>/godot/default/python/lib/python39.zip .
Build Boost-For-Android with iconv support for boost_locale library and python support.
./build-android.sh --with-iconv --arch=arm64-v8a --with-python=`readlink -f ../python-install` --layout=system $ANDROID_NDK
Ensure you got libboost_python<version>.a
and libboost_locale.a
libraries.
Create a build
directory aside the source_directory and change into
this directory. It will contain all compile FreeOrion build artifacs.
<android>/cmake/3.10.2.4988404/bin/cmake -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=21 -DANDROID_NDK=<android>/ndk-bundle/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=<android>/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_CXX_FLAGS=-std=c++14 -DANDROID_ALLOW_UNDEFINED_SYMBOLS=Off -DBUILD_SERVER=OFF -DBUILD_AI=OFF -DBUILD_CLIENT_GG=OFF -DBoost_INCLUDE_DIR=<Boost-for-Android>/build/out/armeabi-v7a/include/ -DBoost_USE_STATIC_LIBS=On -DBoost_LIBRARY_DIR=<Boost-for-Android>/build/out/armeabi-v7a/lib/ -DBUILD_CLIENT_GODOT=On -DICUI18N_LIBRARY=<Boost-for-Android>/libiconv-libicu-android/armeabi-v7a/lib/libicui18n.a -DICUUC_LIBRARY=<Boost-for-Android>/libiconv-libicu-android/armeabi-v7a/lib/libicuuc.a -DICUDATA_LIBRARY=<Boost-for-Android>/libiconv-libicu-android/armeabi-v7a/lib/libicudata.a -DICONV_LIBRARY=<Boost-for-Android>/libiconv-libicu-android/armeabi-v7a/lib/libiconv.so -DPYTHON_LIBRARY=<Python-for-Android>/lib/libpython3.6m.a -DPYTHON_INCLUDE_DIR=<Python-for-Android>/include/python3.6m/ ../freeorion
After successfully creating the Makefiles build the whole project by calling:
<android>/cmake/3.10.2.4988404/bin/cmake --build . -- -j2 VERBOSE=1
After the build finished successfully the godot libraries can be found within
the freeorion-project/build
directory and copied to godot/client/bin/
.
Call strip
on those libraries to clean debug symbols.
Export [Godot-Export-Android] with additional default/*
resources.
To get logs run:
adb exec-out run-as org.godotengine.freeoriongodotclient cat files/freeorion-godot.log