Difference between revisions of "Compiling xoreos"

From xoreos Wiki
Jump to: navigation, search
(Guide for Visual Studio 2017 users)
(CMake)
 
(16 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
==Compiler and build system==
 
==Compiler and build system==
  
xoreos is written in C++, so a C++ compiler, like [https://gcc.gnu.org/ GCC] or [http://clang.llvm.org/ clang] is required. It has two build systems: [https://en.wikipedia.org/wiki/GNU_build_system Autotools] ([https://www.gnu.org/software/autoconf/ Autoconf], [https://www.gnu.org/software/automake/ Automake] and [https://www.gnu.org/software/libtool/ Libtool]) and [https://en.wikipedia.org/wiki/CMake CMake]. Use whichever you feel more comfortable with.
+
xoreos is written in C++, so a C++ compiler, like [https://gcc.gnu.org/ GCC] or [http://clang.llvm.org/ clang] is required. xoreos follows the C++14 standard. It has two build systems: [https://en.wikipedia.org/wiki/GNU_build_system Autotools] ([https://www.gnu.org/software/autoconf/ Autoconf], [https://www.gnu.org/software/automake/ Automake] and [https://www.gnu.org/software/libtool/ Libtool]) and [https://en.wikipedia.org/wiki/CMake CMake]. Use whichever you feel more comfortable with.
  
 
===GNU/Linux===
 
===GNU/Linux===
Line 49: Line 49:
 
** Boost.System
 
** Boost.System
 
** Boost.Filesystem
 
** Boost.Filesystem
** Boost.Regex
 
** Boost.Unordered
 
** Boost.Hash
 
 
** Boost.Date_Time
 
** Boost.Date_Time
** Boost.Function
 
** Boost.Bind
 
 
** Boost.Uuid
 
** Boost.Uuid
 
** Boost.Smart_Ptr
 
** Boost.Smart_Ptr
 
** Boost.ScopeExit
 
** Boost.ScopeExit
** Boost.Atomic
 
 
** Boost.Locale
 
** Boost.Locale
 
* [https://en.wikipedia.org/wiki/OpenGL OpenGL] (>= 2.1)
 
* [https://en.wikipedia.org/wiki/OpenGL OpenGL] (>= 2.1)
* [https://www.libsdl.org/ SDL2] (>= 2.0.0)
+
* [https://www.libsdl.org/ SDL2] (>= 2.0.4)
 
* [http://www.freetype.org/ FreeType 2] (>= 2.4.0 (libtool number >= 11.0.5))
 
* [http://www.freetype.org/ FreeType 2] (>= 2.4.0 (libtool number >= 11.0.5))
 
* [https://en.wikipedia.org/wiki/OpenAL OpenAL] (>= 1.12) ('''See below''')
 
* [https://en.wikipedia.org/wiki/OpenAL OpenAL] (>= 1.12) ('''See below''')
Line 69: Line 63:
 
* [http://www.audiocoding.com/faad2.html libfaad] (>= 2.7)
 
* [http://www.audiocoding.com/faad2.html libfaad] (>= 2.7)
 
* [https://www.xvid.org/ libxvidcore] (>= 1.2.2)
 
* [https://www.xvid.org/ libxvidcore] (>= 1.2.2)
 +
* [https://www.webmproject.org/code/ libvpx] (>= 1.6.0)
  
 
On Debian-based GNU/Linux distribution (including Ubuntu), you should be able to install these libraries and their development packages with
 
On Debian-based GNU/Linux distribution (including Ubuntu), you should be able to install these libraries and their development packages with
Line 74: Line 69:
 
  sudo apt-get install zlib1g-dev liblzma-dev libxml2-dev libboost-all-dev libsdl2-dev \
 
  sudo apt-get install zlib1g-dev liblzma-dev libxml2-dev libboost-all-dev libsdl2-dev \
 
     libfreetype6-dev libopenal-dev libmad0-dev libogg-dev libvorbis-dev libfaad-dev \
 
     libfreetype6-dev libopenal-dev libmad0-dev libogg-dev libvorbis-dev libfaad-dev \
     libxvidcore-dev
+
     libxvidcore-dev libvpx-dev
  
 
On Arch Linux, you can install these dependencies with
 
On Arch Linux, you can install these dependencies with
  
 
  sudo pacman -S zlib xz libxml2 boost boost-libs sdl2 freetype2 openal libmad libogg \
 
  sudo pacman -S zlib xz libxml2 boost boost-libs sdl2 freetype2 openal libmad libogg \
     libvorbis faad2 xvidcore
+
     libvorbis faad2 xvidcore libvpx
  
 
Other GNU/Linux distributions should work similarily.
 
Other GNU/Linux distributions should work similarily.
Line 88: Line 83:
 
     mingw-w64-i686-boost mingw-w64-i686-SDL2 mingw-w64-i686-freetype \
 
     mingw-w64-i686-boost mingw-w64-i686-SDL2 mingw-w64-i686-freetype \
 
     mingw-w64-i686-openal mingw-w64-i686-libmad mingw-w64-i686-libogg \
 
     mingw-w64-i686-openal mingw-w64-i686-libmad mingw-w64-i686-libogg \
     mingw-w64-i686-libvorbis  mingw-w64-i686-faad2 mingw-w64-i686-xvidcore
+
     mingw-w64-i686-libvorbis  mingw-w64-i686-faad2 mingw-w64-i686-xvidcore \
 +
    mingw-w64-i686-libvpx
  
 
On Windows, if you're using MSYS2, you can install these dependencies for 64-bit with
 
On Windows, if you're using MSYS2, you can install these dependencies for 64-bit with
Line 95: Line 91:
 
     mingw-w64-x86_64-boost mingw-w64-x86_64-SDL2 mingw-w64-x86_64-freetype \
 
     mingw-w64-x86_64-boost mingw-w64-x86_64-SDL2 mingw-w64-x86_64-freetype \
 
     mingw-w64-x86_64-openal mingw-w64-x86_64-libmad mingw-w64-x86_64-libogg \
 
     mingw-w64-x86_64-openal mingw-w64-x86_64-libmad mingw-w64-x86_64-libogg \
     mingw-w64-x86_64-libvorbis  mingw-w64-x86_64-faad2 mingw-w64-x86_64-xvidcore
+
     mingw-w64-x86_64-libvorbis  mingw-w64-x86_64-faad2 mingw-w64-x86_64-xvidcore \
 +
    mingw-w64-x86_64-libvpx
  
Windows users not using MSYS2 will have to visit each website manually and download a precompiled version, or, if not available, download the source and compile the library themselves.
+
Windows users not using MSYS2 will have to visit each website manually and download a precompiled version, or, if not available, download the source and compile the library themselves. Alternatively, vcpkg can be used to install most of these libraries.
 
+
===  Guide for Visual Studio 2017 users ===
+
 
+
* Download source from https://github.com/win-iconv/win-iconv and build the library using CMake
+
* Download https://zlib.net/zlib1211.zip, extract and build the library using CMake
+
* Download https://tukaani.org/xz/xz-5.2.4.tar.gz, extract and build the library using the solution file in windows/vs2017
+
* Download ftp://xmlsoft.org/libxml2/libxml2-2.9.8.tar.gz, extract and build the library by following instructions in win32/Readme.txt
+
* Download and install precompiled Boost libraries from https://sourceforge.net/projects/boost/files/boost-binaries/1.67.0/
+
* Download and extract https://www.libsdl.org/release/SDL2-devel-2.0.8-VC.zip
+
* Download https://download.savannah.gnu.org/releases/freetype/ft291.zip and build the library using CMake
+
* Download and extract http://kcat.strangesoft.net/openal-binaries/openal-soft-1.18.2-bin.zip
+
* Download ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz and build the library using the project file in msvc++. To build a 64-bit library, create a new configuration and replace preprocessor definition FPM_INTEL with FPM_64BIT
+
* Download http://downloads.xiph.org/releases/ogg/libogg-1.3.3.zip, extract and build both dynamic and static libraries using solution files in win32/VS2015
+
* Download http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.zip, extract and build both dynamic and static libraries using solution files in win32/VS2010
+
* Download https://vorboss.dl.sourceforge.net/project/faac/faad2-src/faad2-2.8.0/faad2-2.8.8.tar.gz, extract and build projects '''libfaad''' and '''libfaad2_dll''' using the solution file in project/msvc. To build 64-bit libraries, create a new configuration
+
* Download https://downloads.xvid.com/downloads/xvidcore-1.3.5.zip, extract and build the library using the solution file in build/win32 (requires NASM to be installed and present in PATH)
+
  
 
=== A note on OpenAL ===
 
=== A note on OpenAL ===
Line 162: Line 143:
  
 
The binary can be found in the bin subdirectory, called "xoreos" or, on Windows, "xoreos.exe".
 
The binary can be found in the bin subdirectory, called "xoreos" or, on Windows, "xoreos.exe".
 +
 +
This builds xoreos without any optimizations, so you might want to use
 +
 +
<nowiki>cmake -DCMAKE_BUILD_TYPE=Release . && make</nowiki>
 +
 +
(optimized, no debug information) or
 +
 +
<nowiki>cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo . && make</nowiki>
 +
 +
(optimized, with debug information) instead.
  
 
Please read [http://www.cmake.org/runningcmake/ Running CMake] on the CMake website for in-depth information on invoking CMake.
 
Please read [http://www.cmake.org/runningcmake/ Running CMake] on the CMake website for in-depth information on invoking CMake.

Latest revision as of 13:29, 26 August 2020

This page gives a few tips and pointers on how to compile xoreos on various platforms.

Compiler and build system

xoreos is written in C++, so a C++ compiler, like GCC or clang is required. xoreos follows the C++14 standard. It has two build systems: Autotools (Autoconf, Automake and Libtool) and CMake. Use whichever you feel more comfortable with.

GNU/Linux

On Debian-based distributions (including Ubuntu), you should be able to install the required compiler and build system packages with

sudo apt-get install libc6-dev g++ make autoconf automake libtool gettext cmake

On Arch Linux, you can install the necessary packages with

sudo pacman -S base-devel cmake

On other distributions, it should work similarily.

Mac OS X

Due to the dependency on SDL2 (see below), you need at least Mac OS X 10.5 if you use a precompiled SDL2 library, and at least Mac OS X 10.7 if you're compiling SDL2 yourself.

Windows

Since Visual Studio does not work with autotools, you have to use the CMake build system if you want to compile xoreos with Visual Studio. If you're using MinGW, however, you're free to choose either build system.

On Windows, it is recommended that instead of Visual Studio, you use MSYS2 together with Mingw-w64 (which can produce both 32-bit and 64-bit binaries). MSYS2 provides a package manager, with which you can install xoreos' library dependencies very easily.

You can install the 32-bit toolchain in MSYS2 with

pacman -S base-devel git mingw-w64-i686-toolchain mingw-w64-i686-cmake

You can install the 64-bit toolchain in MSYS2 with

pacman -S base-devel git mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake

Libraries

xoreos uses the following libraries to function:

On Debian-based GNU/Linux distribution (including Ubuntu), you should be able to install these libraries and their development packages with

sudo apt-get install zlib1g-dev liblzma-dev libxml2-dev libboost-all-dev libsdl2-dev \
    libfreetype6-dev libopenal-dev libmad0-dev libogg-dev libvorbis-dev libfaad-dev \
    libxvidcore-dev libvpx-dev

On Arch Linux, you can install these dependencies with

sudo pacman -S zlib xz libxml2 boost boost-libs sdl2 freetype2 openal libmad libogg \
    libvorbis faad2 xvidcore libvpx

Other GNU/Linux distributions should work similarily.

On Windows, if you're using MSYS2, you can install these dependencies for 32-bit with

 pacman -S mingw-w64-i686-zlib mingw-w64-i686-xz mingw-w64-i686-libxml2 \
    mingw-w64-i686-boost mingw-w64-i686-SDL2 mingw-w64-i686-freetype \
    mingw-w64-i686-openal mingw-w64-i686-libmad mingw-w64-i686-libogg \
    mingw-w64-i686-libvorbis  mingw-w64-i686-faad2 mingw-w64-i686-xvidcore \
    mingw-w64-i686-libvpx

On Windows, if you're using MSYS2, you can install these dependencies for 64-bit with

 pacman -S mingw-w64-x86_64-zlib mingw-w64-x86_64-xz mingw-w64-x86_64-libxml2 \
    mingw-w64-x86_64-boost mingw-w64-x86_64-SDL2 mingw-w64-x86_64-freetype \
    mingw-w64-x86_64-openal mingw-w64-x86_64-libmad mingw-w64-x86_64-libogg \
    mingw-w64-x86_64-libvorbis  mingw-w64-x86_64-faad2 mingw-w64-x86_64-xvidcore \
    mingw-w64-x86_64-libvpx

Windows users not using MSYS2 will have to visit each website manually and download a precompiled version, or, if not available, download the source and compile the library themselves. Alternatively, vcpkg can be used to install most of these libraries.

A note on OpenAL

On Mac OS X, we're using Apple's OpenAL implementation, so OpenAL does not need to be installed separately there.

On both GNU/Linux and Microsoft Windows, we require OpenAL Soft. There is a propriety OpenAL implementation by Creative Labs, Inc. for Microsoft Windows, which can be found at http://openal.org/, but it's unfortunately old, outdated and abandoned. We do not recommend its use.

Likewise, on NetBSD and other systems using pkgsrc, you should use openal-soft instead of openal.

Compiling xoreos

Make sure you have your compiler, build system and libraries installed correctly. Then open a terminal and change into the directory of your sources.

autotools

Type

./autogen.sh && ./configure && make

The binary can be found in the src subdirectory, called "xoreos" or, on Windows, "xoreos.exe".

Optional, non-conventional ./configure flags:

  • --with-werror  
Compile with -Werror
  • --without-warnings  
Compile without the extra warnings enabled
  • --with-lto  
Compile with link-time optimization
  • --disable-external-glew  
Always compile against the internal GLEW libraries

CMake

Type

cmake . && make

The binary can be found in the bin subdirectory, called "xoreos" or, on Windows, "xoreos.exe".

This builds xoreos without any optimizations, so you might want to use

cmake -DCMAKE_BUILD_TYPE=Release . && make

(optimized, no debug information) or

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo . && make

(optimized, with debug information) instead.

Please read Running CMake on the CMake website for in-depth information on invoking CMake.

Optional, non-conventional cmake flags:

  • -DBoost_USE_STATIC_LIBS=on  
Link Boost statically instead of dynamically
  • -DGLEW_INTERNAL=on  
Always use internal GLEW library

Note: The CMake's stock FindBoost.cmake doesn't correctly detect dependencies when linking statically. In this case, xoreos might fail to link, missing symbols for ICU, when linking Boost statically.

Moreover, if you're running GNU/Linux and have wrapper scripts installed that force the building of "hardened" binaries (often called "hardening-wrapper", but differs between Linux distributions), compiling xoreos might fail during the linking stage, when using statically linking Boost libraries. This is due to those static Boost libraries being incompatible with the compiler option "-fPIE", which is often added by hardening wrapper scripts. A workaround is to disable -fPIE for this compilation (which is distribution-specific).

Unit tests

On both build systems,

make check

compiles and runs our unit tests.

Running xoreos

Please have a look at the Running xoreos page.