Downloading and Compiling under macOS: Difference between revisions

From Arx Libertatis Wiki
Jump to navigation Jump to search
mNo edit summary
(Remove suspected copy-paste error)
 
(42 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This page documents how to compile Arx Libertatis from https://github.com/arx/ArxLibertatis under Mac OS X.
{{DownloadAndCompileNotice|OS=macOS}}
 
This page documents how to compile Arx Libertatis from https://github.com/arx/ArxLibertatis under macOS (formerly OS X).<br>
There are also instructions available for [[Downloading and Compiling under Windows|{{Windows}}]] and [[Downloading and Compiling under Linux|{{Linux}} / {{FreeBSD}}]]


Specific instructions are given for a cleanly installed Lion 10.7.3 system, but the procedure should be similar for other versions.
Specific instructions are given for a cleanly installed Lion 10.7.3 system, but the procedure should be similar for other versions.
== Using Homebrew ==
[https://brew.sh/ Homebrew] greatly simplifies building Arx Libertatis under {{MacOSX}}. After setting up Homebrew, you can use this command to install the latest release version of the [https://formulae.brew.sh/formula/arx-libertatis arx-libertatis] package:
brew install arx-libertatis
To install the development version, use:
brew install --HEAD arx-libertatis


== Setting Up the Build Environment ==
== Setting Up the Build Environment ==


To download and compile Arx Libertatis you will need the following tools:
To download and compile Arx Libertatis you will need the following tools:  
* <code>Xcode</code> Tested with 4.3, install the latest from the App Store (https://developer.apple.com/xcode/)
* <code>Xcode</code> (App Store or https://developer.apple.com/xcode/)
** Install command line tools from Xcode, in Preferences -> Download
* [https://cmake.org/ <code>CMake</code>] 2.8.3 or newer
** Set the path to the Xcode folder: <code>sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer</code>
Optionally you can use either one of these to install the dependencies:
* <code>github for Mac</code> Also install the command line tools (http://mac.github.com/)
* [https://brew.sh/ <code>homebrew</code>]
* <code>cmake</code> should be build from source (http://www.cmake.org/)
* [https://www.macports.org/ <code>MacPorts</code>]
* <code>MacPorts</code> (http://www.macports.org/)
Your system must have the following dependencies installed:
* [https://libsdl.org/ <code>SDL</code>] 2 (recommended), or [https://wwwibsdl.org/ <code>SDL</code>] 1.2.10 or newer
* [https://github.com/anholt/libepoxy <code>libepoxy</code>] 1.2 or newer (recommended), or [http://glew.sourceforge.net/ <code>GLEW</code>] 1.5.2 or newer
* <code>OpenAL</code> ([https://openal-soft.org/ OpenAL Soft] is strongly recommended)
* [https://www.boost.org/ <code>Boost</code>] 1.50 or newer (headers only)
* [https://glm.g-truc.net/ <code>GLM</code>] 0.9.5.0 or newer
* [https://www.freetype.org/ <code>FreeType</code>] 2.3.0 or newer
<code>OpenGL</code> and <code>zlib</code> are already bundled with macOS. <code>OpenAL</code> is also bundled with macOS but deprecated.
You can also install [https://git-scm.com/ <code>git</code>] if you want to compile the development version.


== Libraries ==
=== Example ===
* <code>SDL</code> 1.2 (http://www.libsdl.org/)
* <code>GLEW</code> (http://glew.sourceforge.net/)
* <code>DevIL</code> (http://openil.sourceforge.net/)
* <code>zlib</code> (http://zlib.net/)
* <code>Boost</code> headers and program_options library (http://www.boost.org/)
* <code>Freetype</code> (http://www.freetype.org/)
* <code>OpenGL</code> Nothing to do... Framework is bundled with Xcode
* <code>OpenAL</code> Nothing to do... Framework is bundled with Xcode


I installed those using MacPorts... but you can probably obtain "native" versions too.  
* Download and install the latest version of Xcode from the App Store or from https://developer.apple.com/xcode/, depending on your OS version
* zLib: <code>sudo port install zlib</code>
* Install command line tools from Xcode, in Preferences -> Download
* freetype: <code>sudo port install freetype</code>
* Set the path to the Xcode folder:
* devil: <code>sudo port install libdevil</code>
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
* boost: <code>sudo port install boost</code>
After installing Xcode you can either use homebrew or MacPorts to install the dependencies.
* qt: <code>sudo port install qt4-mac</code>
Using homebrew is recommended because most of the dependencies are already bottled, that is, they will not have to be compiled.
* sdl: <code>sudo port install libsdl</code>
*NOTE: do not install both as they tend to generate issues when installed on the same system
* glew: <code>sudo port install glew</code>


Or as a single line:
==== <code>homebrew</code> ====
sudo port install zlib freetype libdevil boost qt4-mac libsdl glew


== Cloning the code repository ==
* Install <code>homebrew</code>:
=== Using GitHub for Mac ===
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Refer to http://mac.github.com/help.html :)
* Install the dependencies with homebrew:
brew install cmake boost freetype sdl2 libepoxy qt5 cppunit glm openal-soft


=== From the command line ===
==== <code>MacPorts</code> ====
First, go to where you want the ArxLibertatis directory to be located.
cd ~/Code


You are now ready to clone the repository, type:
* Download and install CMake from https://cmake.org/
git clone git://github.com/arx/ArxLibertatis.git
* Download and install MacPorts from https://www.macports.org/
* Install the dependencies with MacPorts:
sudo port install libsdl libepoxy boost glm freetype
*NOTE: These packages take a long time to build. Do not be discouraged if it seems like nothing is happening.


This creates a directory called ArxLibertatis and downloads the current source code from github.
== Getting the source code ==
cd ArxLibertatis
 
If you want to compile the development version, first install git with homebrew (<code>brew install git</code>) or from https://git-scm.com/.
*WARNING: last time I tried the development version failed to compile, you should download the latest release instead.
{{GetTheSourceCode}}


== Compiling ==
== Compiling ==


=== Building CMake from source ===
=== Preparing the build directory ===
The latest release of CMake (2.8.7) still has issues with Xcode 4.3, but it's been fixed in the development branch. You can build cmake from source to fix this:
 
git clone http://cmake.org/cmake.git
First, <code>cd</code> to where you downloaded / extracted the AL source code (the directory containing the `CMakeLists.txt` file):
  cd cmake
 
./configure
  cd ArxLibertatis
make
sudo make install


You're now ready to generate makefiles or an Xcode project. cd to the root of the arx repository
Then create a build directory that will contain compiled files.


=== Makefiles ===
  mkdir build
  mkdir build
  cd build
  cd build
=== Using the data repository (git checkouts only) ===
Next, tell the build system where to find the ArxLibertatisData repo (you can skip this if you want to generate the data files yourself or if you are building from a release source archive):
ln -s ../../ArxLibertatisData arx-libertatis-data
Replace <code>../../ArxLibertatisData</code> with the path to the ArxLibertatisData checkout. Alternatively you can pass the <code>-DDATA_FILES=../../ArxLibertatisData</code> option to the cmake command(s) below.
=== Configuring ===
Now you should be ready to configure and compile.  Run cmake:
  cmake ..
  cmake ..
<font color=#666>If you plan on adding code, it might be a good idea to use the developer mode instead:</font>
<font color=#666>cmake .. -DDEVELOPER=1</font>
<font color=#666>This disables the unity build to allow for faster incremental builds and also enables runtime checks and debug output in the compiled binary.</font>
=== Building ===
And now you should be able to compile with:
  make
  make


If you run out of RAM during the build, disable the unity build by running cmake like this and try make again:
cmake .. -DUNITY_BUILD=0
Finally, you can install the executable system-wide with:
sudo make install
Enter your account password at the prompt.
<!--
=== Xcode project ===
=== Xcode project ===
  mkdir build_xcode
  mkdir build_xcode
  cd build_xcode
  cd build_xcode
  cmake .. -G Xcode
  cmake .. -G Xcode
  open ArxLibertatis.xcodeproj/
  open ArxLibertatis.xcodeproj/
Then compile and run the project from Xcode. (?)
-->
== Running the executable ==
You can run the Arx Libertatis executable from the terminal:
arx
You will need to [[Getting the game data|obtain a copy of the data]] files from a commercial copy of Arx Fatalis, or use the demo data files. Refer to [[Installing the game data under Linux]] regarding where and how to install the game data. <code>innoextract</code> can also be installed with homebrew (<code>brew install innoextract</code>).
The game will automatically change all used files to lower-case on the first start. If you want to run the game with read-only data you need to do this manually.
For running arx in a debugger, see [[Debugging]]
=== Creating an .app wrapper ===
If you want to have an icon you can pin on your dock or in your launchpad you can create a simple AppleScript to wrap the executable in an .app bundle.
* First, determine where the <code>arx</code> executable is.
** If you didn't <code>make install</code> figure out the path to the folder you built it to.
** If you ran <code>make install</code>, use this to find out the position of the executable, then copy the output:
which arx
* Open AppleScript Editor (it should be in <code>Applications/Utilities/</code>)
* Assuming the path to <code>arx</code> is <code>/usr/local/bin/arx</code>, copy the following lines into the window:
to run
do shell script "/usr/local/bin/arx"
end run
Replace <code>/usr/local/bin/arx</code> with the position of your executable if needed.
* Save the script as an application.
<!--
==== Adding an icon ====
* Download the icon file (link should be here).
* Right click on the .app bundle and choose "Get info", and do the same with the .icns file.
* Drag the icon from the .icns file info box to the .app's
-->

Latest revision as of 00:12, 13 December 2023

ℹ️  This page describes compiling Arx Libertatis from source under macOS 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 macOS (formerly OS X).
There are also instructions available for Windows and Linux / FreeBSD

Specific instructions are given for a cleanly installed Lion 10.7.3 system, but the procedure should be similar for other versions.

Using Homebrew

Homebrew greatly simplifies building Arx Libertatis under macOS. After setting up Homebrew, you can use this command to install the latest release version of the arx-libertatis package:

brew install arx-libertatis

To install the development version, use:

brew install --HEAD arx-libertatis

Setting Up the Build Environment

To download and compile Arx Libertatis you will need the following tools:

Optionally you can use either one of these to install the dependencies:

Your system must have the following dependencies installed:

  • SDL 2 (recommended), or SDL 1.2.10 or newer
  • libepoxy 1.2 or newer (recommended), or GLEW 1.5.2 or newer
  • OpenAL (OpenAL Soft is strongly recommended)
  • Boost 1.50 or newer (headers only)
  • GLM 0.9.5.0 or newer
  • FreeType 2.3.0 or newer

OpenGL and zlib are already bundled with macOS. OpenAL is also bundled with macOS but deprecated. You can also install git if you want to compile the development version.

Example

  • Download and install the latest version of Xcode from the App Store or from https://developer.apple.com/xcode/, depending on your OS version
  • Install command line tools from Xcode, in Preferences -> Download
  • Set the path to the Xcode folder:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

After installing Xcode you can either use homebrew or MacPorts to install the dependencies. Using homebrew is recommended because most of the dependencies are already bottled, that is, they will not have to be compiled.

  • NOTE: do not install both as they tend to generate issues when installed on the same system

homebrew

  • Install homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
  • Install the dependencies with homebrew:
brew install cmake boost freetype sdl2 libepoxy qt5 cppunit glm openal-soft

MacPorts

sudo port install libsdl libepoxy boost glm freetype
  • NOTE: These packages take a long time to build. Do not be discouraged if it seems like nothing is happening.

Getting the source code

If you want to compile the development version, first install git with homebrew (brew install git) or from https://git-scm.com/.

  • WARNING: last time I tried the development version failed to compile, you should download the latest release instead.

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.

Compiling

Preparing the build directory

First, cd to where you downloaded / extracted the AL source code (the directory containing the `CMakeLists.txt` file):

cd ArxLibertatis

Then create a build directory that will contain compiled files.

mkdir build
cd build

Using the data repository (git checkouts only)

Next, tell the build system where to find the ArxLibertatisData repo (you can skip this if you want to generate the data files yourself or if you are building from a release source archive):

ln -s ../../ArxLibertatisData arx-libertatis-data

Replace ../../ArxLibertatisData with the path to the ArxLibertatisData checkout. Alternatively you can pass the -DDATA_FILES=../../ArxLibertatisData option to the cmake command(s) below.

Configuring

Now you should be ready to configure and compile. Run cmake:

cmake ..

If you plan on adding code, it might be a good idea to use the developer mode instead:

cmake .. -DDEVELOPER=1

This disables the unity build to allow for faster incremental builds and also enables runtime checks and debug output in the compiled binary.

Building

And now you should be able to compile with:

make

If you run out of RAM during the build, disable the unity build by running cmake like this and try make again:

cmake .. -DUNITY_BUILD=0

Finally, you can install the executable system-wide with:

sudo make install

Enter your account password at the prompt.


Running the executable

You can run the Arx Libertatis executable from the terminal:

arx

You will need to obtain a copy of the data files from a commercial copy of Arx Fatalis, or use the demo data files. Refer to Installing the game data under Linux regarding where and how to install the game data. innoextract can also be installed with homebrew (brew install innoextract).

The game will automatically change all used files to lower-case on the first start. If you want to run the game with read-only data you need to do this manually.

For running arx in a debugger, see Debugging

Creating an .app wrapper

If you want to have an icon you can pin on your dock or in your launchpad you can create a simple AppleScript to wrap the executable in an .app bundle.

  • First, determine where the arx executable is.
    • If you didn't make install figure out the path to the folder you built it to.
    • If you ran make install, use this to find out the position of the executable, then copy the output:
which arx
  • Open AppleScript Editor (it should be in Applications/Utilities/)
  • Assuming the path to arx is /usr/local/bin/arx, copy the following lines into the window:
to run
	do shell script "/usr/local/bin/arx"
end run

Replace /usr/local/bin/arx with the position of your executable if needed.

  • Save the script as an application.