Downloading and Compiling under Windows: Difference between revisions

From Arx Libertatis Wiki
Jump to navigation Jump to search
(Cleanup and minor improvements.)
(Build options and misc. fixes)
Line 12: Line 12:


* [http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop '''Visual C++ 2013 Express Edition''']
* [http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop '''Visual C++ 2013 Express Edition''']
** Other Visual Studio version should also work.
** Other Visual Studio versions should also work.
* [http://www.cmake.org/cmake/resources/software.html '''CMake''']
* [http://www.cmake.org/cmake/resources/software.html '''CMake''']
** For CMake installation guide, please visit http://johnlamp.net/cmake-tutorial-1-getting-started.html
** For CMake installation guide, please visit http://johnlamp.net/cmake-tutorial-1-getting-started.html
Line 19: Line 19:
** For MinGW installation guide, please visit http://ingar.satgnu.net/devenv/mingw32/base.html.
** For MinGW installation guide, please visit http://ingar.satgnu.net/devenv/mingw32/base.html.
** In the installer, make sure you check msys-base
** In the installer, make sure you check msys-base
* [http://git-scm.com/downloads '''msysgit''']
* [http://git-scm.com/downloads '''Git for Windows''']


=== Optional Applications ===
=== Optional Applications ===


* Optional: [http://code.google.com/p/tortoisegit/ '''TortoiseGit''']: For better Git GUI.
* [http://code.google.com/p/tortoisegit/ '''TortoiseGit''']: For better Git GUI.
* Optional: [http://www.stack.nl/~dimitri/doxygen/ '''Doxygen''']: For developer documentation.
* [http://www.stack.nl/~dimitri/doxygen/ '''Doxygen''']: For developer documentation.
* Optional: If you want to use the crash reporter or profiler, you need to [http://www.qt.io/download/ download and install Qt5].
* [http://www.qt.io/download/ '''Qt5''']: If you want to use the crash reporter or profiler.
**You also need to append the full path to Qt's msvc2013 or msvc2013_64 directory to your <code>CMAKE_PREFIX_PATH</code>. This directory is in the Qt\[Version number] folder.
**You will need to append the full path for Qt's msvc2013 or msvc2013_64 directory to your <code>CMAKE_PREFIX_PATH</code> ([[#How to obtain them|See below for instructions]]). This directory is in the Qt\[Version number] folder.


== Step 2: Getting the libraries ==
== Step 2: Getting the libraries ==


Getting all libraries to work under Windows required a lot of work and was error prone. Now we provide pre-built versions on [https://github.com/arx/ArxWindows the ArxWindows repo] (both 32-bit and 64-bit) to simplify the process.
Getting all libraries to work under Windows used to require a lot of work and was error prone. Now we provide pre-built versions on [https://github.com/arx/ArxWindows the ArxWindows repo] (both 32-bit and 64-bit) to simplify the process.


Windows Arx Libertatis depends on the following libraries:
Windows Arx Libertatis depends on the following libraries:
Line 43: Line 43:
* <code>FreeType</code> 2.3.0 or newer (http://www.freetype.org/)
* <code>FreeType</code> 2.3.0 or newer (http://www.freetype.org/)


#The ArxWindows repo only contains the Boost source, it doesn't contain any prebuilt libraries - those aren't needed for Arx Libertatis.
#The ArxWindows repo only contains the Boost source. It doesn't contain any prebuilt libraries - those aren't needed for Arx Libertatis.


#Creative's OpenAL implementation is severely limited, which can cause missing sounds in arx. OAL implementations from IHVs are buggy and the cause of many crash reports.
#Creative's OpenAL implementation is severely limited, which can cause missing sounds in Arx. OAL implementations from IHVs (Independent Hardware Vendors) are buggy and the cause of many crash reports.


All of the above can be obtained from the ArxWindows repo.
All of the above can be obtained from the ArxWindows repo.


===How to obtain them:===
===How to obtain them===


In GitBash
In GitBash
Line 59: Line 59:
On Windows 7 or later this can be done here:<br> [[File:Win7_env.png|400px]]
On Windows 7 or later this can be done here:<br> [[File:Win7_env.png|400px]]


After that, you need to start a new prompt (GitBash, Command Prompt, etc) so that the new environment variables are available.
After that, you'll need to start a new Gitbash prompt so that the new environment variables are available.


Run the following to check if you set the cmake path correctly or not:  
Run the following to check if you set the CMake path correctly or not:  
  echo $CMAKE_PREFIX_PATH
  echo $CMAKE_PREFIX_PATH
It should echo:
It should echo:
Line 77: Line 77:
  cmake .. -G "Visual Studio 12" -DUNITY_BUILD=ON
  cmake .. -G "Visual Studio 12" -DUNITY_BUILD=ON


* "Visual Studio 12" in the command refers to using Visual Studio 2013 to generate the project. If you are using Visual Studio 2012, use ""Visual Studio 11" instead. Use <code>cmake --help</code> to check the available compilers on your computer.
* "Visual Studio 12" in the command refers to using Visual Studio 2013 to generate the project. If you are using a different version, change the number accordingly. Use <code>cmake --help</code> to check the available compilers on your computer.
* This line will create 32-bit project files. If you wish to build Arx in x64, you will need to replace "Visual Studio 12" with "Visual Studio 12 2013 Win64" (varying the version number and year according to your VS version, of course).
 
===Build Options===
 
* -DUNITY_BUILD=ON enables building of each program as one big source file. This is somewhat like link-time optimization but provides faster builds as each header only needs to be parsed once for the whole executable. It also prevents incremental builds - if you plan on using <code>git bisect</code> or trying a lot of small changes, consider leaving it out.
* -DUNITY_BUILD=ON enables building of each program as one big source file. This is somewhat like link-time optimization but provides faster builds as each header only needs to be parsed once for the whole executable. It also prevents incremental builds - if you plan on using <code>git bisect</code> or trying a lot of small changes, consider leaving it out.
* -DBUILD_TOOLS Defaults to ON and affects whether the project will build arxsavetool and arxunpak. Set this with the value =OFF to prevent these tools being built.
* -DBUILD_IO_LIBRARY (default=ON): Affects building of the helper library for the Blender plugin.
* -DBUILD_CRASHREPORTER (default=ON): Affects building of the crash reporter gui (default OFF for Mac). Note: This will not be built unless you have [[#Optional Applications|setup Qt]].
* -DDEBUG_EXTRA (default=OFF): Enables expensive debug options (on top of those enabled in regular debug builds).
* -DBUILD_PROFILER_INSTRUMENT (Default =OFF): When built with this flag, Arx will dump profiler data when f12 is pressed in-game. This is useful for diagnosing performance issues. The file(s) generated will be stored in the Arx main folder as [date and time].arxprof and require the profiler to open.
* -DBUILD_PROFILER : Builds the profiler GUI, for opening .arxprof files. Also [[#Optional Applications|requires Qt]].


For further build options, please refer to the [https://github.com/arx/ArxLibertatis/blob/master/README.md#build-options README file].
It is easier to add, remove and edit these options in the CMake GUI than in GitBash.


== Step 5: Building Arx Libertatis ==
== Step 5: Building Arx Libertatis ==

Revision as of 00:35, 23 August 2015

ℹ️  This page describes compiling Arx Libertatis from source under Windows and assumes some familiarity with the command-line. If you just want to play the game, it might be easier to grab a binary release or snapshot if available.

This page documents how to compile Arx Libertatis from https://github.com/arx/ArxLibertatis under Windows.

There are also instructions available for Linux / FreeBSD and macOS

This guide assumes use of Visual Studio 2013, but should also work with any version of Visual Studio. All file paths used here are an example (using C:\Code\Git as a base).

There is a YouTube video that goes through this process in depth: https://www.youtube.com/watch?v=2h9O82Zf3Gk

Step 1: Download Required Applications

Optional Applications

  • TortoiseGit: For better Git GUI.
  • Doxygen: For developer documentation.
  • Qt5: If you want to use the crash reporter or profiler.
    • You will need to append the full path for Qt's msvc2013 or msvc2013_64 directory to your CMAKE_PREFIX_PATH (See below for instructions). This directory is in the Qt\[Version number] folder.

Step 2: Getting the libraries

Getting all libraries to work under Windows used to require a lot of work and was error prone. Now we provide pre-built versions on the ArxWindows repo (both 32-bit and 64-bit) to simplify the process.

Windows Arx Libertatis depends on the following libraries:

  1. The ArxWindows repo only contains the Boost source. It doesn't contain any prebuilt libraries - those aren't needed for Arx Libertatis.
  1. Creative's OpenAL implementation is severely limited, which can cause missing sounds in Arx. OAL implementations from IHVs (Independent Hardware Vendors) are buggy and the cause of many crash reports.

All of the above can be obtained from the ArxWindows repo.

How to obtain them

In GitBash

cd /c/Code/git
git clone --depth 1 git://github.com/arx/ArxWindows.git

Then we need to tell CMake where to search for our libraries: Add CMAKE_PREFIX_PATH to your environment variable with the following value:

C:\Code\git\ArxWindows\libs\zlib;C:\Code\git\ArxWindows\libs\freetype;C:\Code\git\ArxWindows\libs\openal;C:\Code\git\ArxWindows\libs\boost;C:\Code\git\ArxWindows\libs\glm;C:\Code\git\ArxWindows\libs\opengl;C:\Code\git\ArxWindows\libs\sdl;C:\Code\git\ArxWindows\libs\dbghelp

On Windows 7 or later this can be done here:
Win7 env.png

After that, you'll need to start a new Gitbash prompt so that the new environment variables are available.

Run the following to check if you set the CMake path correctly or not:

echo $CMAKE_PREFIX_PATH

It should echo:

C:\Code\git\ArxWindows\libs\zlib;C:\Code\git\ArxWindows\libs\freetype;C:\Code\git\ArxWindows\libs\openal;C:\Code\git\ArxWindows\libs\boost;C:\Code\git\ArxWindows\libs\glm;C:\Code\git\ArxWindows\libs\opengl;C:\Code\git\ArxWindows\libs\sdl;C:\Code\git\ArxWindows\libs\dbghelp

Step 3: Getting the source code

There are several methods to get the Arx Libertatis source code - choose the one that suits you best:

Downloading a released version

The easiest way to get the AL source code is to download a versioned release. This will get you a reasonably up to date copy of the source code that has been tested to work.

Cloning the repository

If you want the absolute latest version of the Arx Libertatis development code and stay up to date, you can clone the AL source code repository. Beware that this will give you the current master development branch that we are actively working on. While the code in that branch should always work, it hasn't undergone any significant testing. If you just want to play the game, consider using a released version instead.

To clone the repository, type:

git clone git://github.com/arx/ArxLibertatis.git

This creates a directory called ArxLibertatis and downloads the current source code from github.

Later if you want to update your local copy of the source code, run

git pull

The git repository does not contain raster images for the icon and logo. These will be generated from scalable versions when building Arx Libertatis, but doing so requires additional dependencies (Inkscape, ImageMagick and OptiPNG). To avoid this, you can instead get the generated images from the ArxLibertatisData repo:

git clone --depth 1 git://github.com/arx/ArxLibertatisData.git

Downloading a snapshot

Alternatively you can download the current snapshot of the source code repository as a .zip or .tar.gz file and extract that:

This will give you the same code as cloning the repository, but won't let you update it without downloading everything again.

Step 4: Generating VC++ projects

We'll use CMake for that in GitBash:

mkdir build_vc12
cd build_vc12
cmake .. -G "Visual Studio 12" -DUNITY_BUILD=ON
  • "Visual Studio 12" in the command refers to using Visual Studio 2013 to generate the project. If you are using a different version, change the number accordingly. Use cmake --help to check the available compilers on your computer.
  • This line will create 32-bit project files. If you wish to build Arx in x64, you will need to replace "Visual Studio 12" with "Visual Studio 12 2013 Win64" (varying the version number and year according to your VS version, of course).

Build Options

  • -DUNITY_BUILD=ON enables building of each program as one big source file. This is somewhat like link-time optimization but provides faster builds as each header only needs to be parsed once for the whole executable. It also prevents incremental builds - if you plan on using git bisect or trying a lot of small changes, consider leaving it out.
  • -DBUILD_TOOLS Defaults to ON and affects whether the project will build arxsavetool and arxunpak. Set this with the value =OFF to prevent these tools being built.
  • -DBUILD_IO_LIBRARY (default=ON): Affects building of the helper library for the Blender plugin.
  • -DBUILD_CRASHREPORTER (default=ON): Affects building of the crash reporter gui (default OFF for Mac). Note: This will not be built unless you have setup Qt.
  • -DDEBUG_EXTRA (default=OFF): Enables expensive debug options (on top of those enabled in regular debug builds).
  • -DBUILD_PROFILER_INSTRUMENT (Default =OFF): When built with this flag, Arx will dump profiler data when f12 is pressed in-game. This is useful for diagnosing performance issues. The file(s) generated will be stored in the Arx main folder as [date and time].arxprof and require the profiler to open.
  • -DBUILD_PROFILER : Builds the profiler GUI, for opening .arxprof files. Also requires Qt.

It is easier to add, remove and edit these options in the CMake GUI than in GitBash.

Step 5: Building Arx Libertatis

Build the whole solution (ArxLibertatis.sln) in Visual Studio: C:\Code\git\ArxLibertatis\build_vc12\ArxLibertatis.sln as shown in the picture.
BuildSolution.png

You can build the debug target (has debug symbols & can be debugged) or the release target (faster, but currently without debug information)

Step 6: Installing the data files

After getting the game data, you need to put the data files in a location where Arx Libertatis can find them.

By default, Arx Libertatis searches for data files (from the original game) under the following paths:

  • C:\Code\git\ArxLibertatis\build_vc12 <--preferred
  • C:\Code\git\ArxLibertatis\data\core
  • C:\Users\[YOUR NAME]\Saved Games\Arx Libertatis

Simply place your data files into one of these directories.

    • If you want to specify your own data file location, create a Window registry key HKCU\Software\ArxLibertatis\DataDir with the value pointing to your game data directory.
    • Arx Libertatis only needs the following data files:
      • data.pak
      • data2.pak
      • loc.pak
      • sfx.pak
      • speech.pak

Finally, copy the necessary dlls to C:\Code\git\ArxLibertatis\build_vc12\Debug because that's where your arx.exe is located

C:\Code\git\ArxWindows\libs\sdl\bin\SDL32.dll  \\if you are using 32-bit Windows
C:\Code\git\ArxWindows\libs\sdl\bin\SDL64.dll  \\if you are using 64-bit Windows

The complete search path is described on the Data directories page.

Step 7: Running Arx Libertatis

Simply click on arx.exe under C:\Code\git\ArxLibertatis\build_vc12\Debug or \build_vc12\Release

Step 8: Debugging ArxLibertatis

  • Right click on the 'arx' project under the Solution Explorer in Visual Studio 2013
  • Select "Set as StartUp Project"
  • Change full_screen to false in %USERPROFILE%\Saved Games\Arx Libertatis\cfg.ini, as debugging in fullscreen is a pain.
    • Otherwise, you can change to full_screen after you run the game.
  • Click the "debug" button (F5) and enjoy :D
  • For Arx Libertatis debug explanation, please check out Debugging