How to compile

From Tales of Maj'Eyal
Revision as of 04:00, 13 March 2020 by Braindead (Talk | contribs) (Troubleshooting: libvorbis section added)

Jump to: navigation, search

These are instructions for compiling ToME4 on Debian Linux. If you haven't done so already, see Source Setup for obtaining the source code.

Building ToME4 beta 43 or higher requires snapshots of the currently unreleased SDL 2.0 library (also referred to as SDL HG). Most operating systems only supply the latest stable release, SDL 1.2, which will not work for ToME4.

In addition, you will need SDL2-compatible versions of the SDL_image and SDL_ttf libraries. Again, these are typically not available from your operating system distributor, because they are in a prerelease state. The instructions on this page will guide you through the process of building these from source.

Addons

The ToME 1.0.0RC1 (and later) source code in Git/SVN is incomplete. You must install "addons" which are not part of the Git/SVN tree in order to get all the game features. The procedure recommended by DarkGod is to download one of the official releases, extract the addon files from it, and copy them into the tree.

If you prefer to avoid doing that, the addons are available from a third-party site:

Game Version Addons
1.1.3 tome-addon-dev.teaa
tome-items-vault.teaa
tome-stone-wardens.teaa
1.0.1 tome-items-vault.teaa
tome-stone-wardens.teaa
1.0.0 tome-items-vault.teaa
tome-stone-wardens.teaa
RC4 tome-items-vault.teaa
tome-stone-wardens.teaa
RC2 tome-items-vault.teaa
tome-stone-wardens.teaa
RC1 tome-items-vault.teaa
tome-stone-wardens.teaa

Copy these into the game/addons/ subdirectory once you've followed the rest of the instructions below.

Addons are version-locked to the specific ToME version for which they are bundled, except ToME versions above 1.0.1, which can use the 1.0.1 addons.

SDL

ToME beta 43 was built with the prerelease versions of SDL2, SDL2_image and SDL2_ttf available on November 25, 2012. Later versions may also work, depending on the stability of the library's interface. For reference, the following hg revision numbers are known to work:

  • SDL revision 6687
  • SDL_image revision 339
  • SDL_ttf revision 222

(You should try the current SDL2 first, and only fall back to these older versions if necessary.)

Install prerequisite development packages for your operating system. You'll need mercurial (hg), C and C++ compilers, make, autoconf and friends, and the development packages for X, libopenal, libogg, libvorbis, libpng, libglu1-mesa, libfreetype, libasound, and libaudiofile.

For Debian, this might work:

sudo apt-get build-dep libsdl1.2debian
sudo apt-get install subversion mercurial autoconf automake libtool

If that doesn't work, then this may get you close:

sudo apt-get install build-essential subversion mercurial
sudo apt-get install autoconf automake libtool
sudo apt-get install libopenal-dev libogg-dev libpng12-dev libvorbis-dev
sudo apt-get install libglu1-mesa-dev libfreetype6-dev xorg-dev
sudo apt-get install libasound2-dev libaudiofile-dev

Install the prerelease version of SDL2:

cd /usr/local/src
hg clone http://hg.libsdl.org/SDL
cd SDL
# OPTIONAL: hg update 6687
./autogen.sh
cd ..
mkdir SDL-build
cd SDL-build
../SDL/configure && make && sudo make install
sudo ldconfig

Install the prerelease version of SDL_image:

cd /usr/local/src
hg clone http://hg.libsdl.org/SDL_image
cd SDL_image
# OPTIONAL: hg update 339
./autogen.sh
cd ..
mkdir SDL_image-build
cd SDL_image-build
../SDL_image/configure && make && sudo make install
sudo ldconfig


Install the prerelease version of SDL_ttf:

cd /usr/local/src
hg clone http://hg.libsdl.org/SDL_ttf
cd SDL_ttf
# OPTIONAL: hg update 222
./autogen.sh
cd ..
mkdir SDL_ttf-build
cd SDL_ttf-build
../SDL_ttf/configure && make && sudo make install
sudo ldconfig

Note, the configure command might throw errors about Freetype2. Installation instructions can be found here.

At this point you should have headers in /usr/local/include/SDL2/ and libraries in /usr/local/lib/. The libraries should be named libSDL2, libSDL2_image and libSDL2_ttf (with appropriate version numbers and extensions). If any of the SDL libraries fail to build, check the SDL website for assistance.

Premake4

Install premake4 from your distro:

sudo apt-get install premake4

Another option is to install premake4 from https://premake.github.io/

Note: if your OS has a "premake" version 3 package, that will not work.

ToME4

Decide where you'll keep the ToME source code. You'll need about 1 gigabyte of space. Let's assume you're going to use /usr/local/src/t-engine4. Make this directory and make sure you have write permission.

Fetch the ToME sources:

cd /usr/local/src
git clone http://git.net-core.org/tome/t-engine4.git

Your local copy of the Git repository will contain every version of ToME source code up to the time you did the clone, and you will be "checked out" in the bleeding edge master branch by default. So, if you want to build a stable version of ToME, you need to specify which one:

cd t-engine4
git checkout tome-1.1.3       # or whichever remote tag you wish to "check out"

Check, and possibly edit, premake4.lua and build/te4core.lua to reflect the location of your SDL installation.

  • In premake4.lua, make sure "/usr/local/include/SDL2" appears before any other SDL directory in the includedirs section.
  • In build/te4core.lua, under the configuration "linux" section, make sure "/usr/local/lib/" appears on the libdirs line, and make sure "SDL2", "SDL2_ttf", "SDL2_image" appear on the links line.

Now to compile, you just do:

cd /usr/local/src/t-engine4
make clean; premake4 clean     # Don't worry if these fail.
premake4 gmake
make

To upgrade to a new version:

cd /usr/local/src/t-engine4
make clean; premake4 clean     # Don't worry if these fail.
git fetch origin
git merge origin
git checkout tome-x.y.z        # Fill in the appropriate remote tag name

Then you need to check/edit premake4.lua and build/te4core.lua again (every time, sigh), and then finally:

premake4 gmake
make

Troubleshooting

If you get an error like this:
Lua Error: /engine/utils.lua:666: could not load font: /data/font/Vera.ttf (12)

It means you've linked against the wrong versions of SDL_image and/or SDL_ttf. Make sure ToME is linked against the new versions, which have "SDL2" in their names.

If you get an error like this:
Error initializing SDL video:  No available video device

It probably means you didn't have all the development packages installed when you built SDL.

If you get an error like this:
In file included from ../src/main.c:41:
../src/music.h:43:10: fatal error: AL/al.h: No such file or directory
 #include <AL/al.h>

It means you don't have OpenAL libs and/or headers installed. Install both using:

sudo apt-get install libopenal1 libopenal-dev
If you get an error like this:
In file included from ../src/main.c:41:
../src/music.h:45:10: fatal error: vorbis/vorbisfile.h: No such file or directory
 #include <vorbis/vorbisfile.h>

It means you don't have the Vorbis libs and/or headers installed. Install both using:

sudo apt-get install libvorbis0a libvorbis-dev