User Tools

Site Tools


wiki:data:pages:server:server_compiling

Compiling the Crossfire Server

This document describes how to build and install the Crossfire server from source. Instructions for building the client are on a separate page.

*Nix Compile Guide

Requirements

It's likely that many of these packages (listed alphabetically) are already installed on your system, but this list is a way to make sure. It's important to have all the right packages in place before attempting any builds or compiles.

  • automake - A tool for generating GNU Standards-compliant Makefiles
  • flex - A fast lexical analyzer generator
    • m4 - a macro processing language (required by flex)
  • gcc - The GNU C compiler
  • libgd-tools - GD command line tools and example code
    • libgd2-noxpm - GD Graphics Library version 2 (without XPM support) (required by libgd-tools)
  • libgd2-xpm-dev - GD Graphics Library version 2 (development version)
  • libtool - Generic library support script
  • make - The GNU version of the “make” utility
  • python-dev - header files and a static library for Python (default)
  • subversion - advanced version control system (aka. svn)
    • libapr0 - the Apache Portable Runtime (required by subversion)
    • libsvn0 - shared libraries used by Subversion (aka. svn) (required by subversion)

As a quick reference:

sudo apt-get install automake flex gcc libgd-tools libgd2-xpm-dev libtool make python-dev subversion

Python Scripting

A special note about installing python. The package listed above, python-dev, should install the necessary packages to enable many of the in-game features (ship transportation, guilds, post office, et al.) to work.

However, if python related features are not working, then installing python depends on your choice of Linux distro.

  • python 2.4 is old, Crossfire runs with 2.5 and 2.6; I would use 2.6 if possible, has not been tried with 3.1
  • lib64python2.4-2.4.3 is known to work on Mandriva 2007.0 x86_64
  • python2.6-dev is known to work with Ubuntu Lucid (10.04.4)
  • python2.7-dev is known to work in Ubuntu Precise (12.04) and Trusty (14.04)

As an example, this is what you would use to install python on Ubuntu Trusty Tahr:

sudo apt-get install python2.7-dev

To confirm python is fully installed

 $ python

and you should see an output like:

   Python 2.7.3 (default, Apr 10 2013, 06:20:15)
   [GCC 4.6.3] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>>

If you see something like the above, python is installed, ctrl-d to quit python.

The recommended packages provide additional add-ons or features (summaries included, below) to the server or as a way to test new functions and features.

  • autoconf - automatic configure script builder (Not normally required for end-user builds, but it is useful if build scripts are not up to date)
  • check - unit test framework for C (used by the unit tests)
  • libsqlite3-0 - SQLite 3 shared library (used by cflogger)
  • libpython2.4 - Python shared object library (used by game features such as bank, post office, slot machines, etc.)
  • libpython2.4-devel - Required to compile python support into the server
  • libcurl3 - - Multi-protocol file transfer library (required by metaserver2)
  • libcurl4-openssl-dev - Development files and documentation for libcurl (OpenSSL) (required by metaserver2)
  • libsvn-dev - Development files for Subversion libraries (required for Subversion revision number reporting in metaserver2)

As a quick reference:

sudo apt-get install check autoconf libsqlite3-0 libcurl3 libcurl4-openssl-dev libsvn-dev

Useful Packages

These useful packages are not normally required for end-user builds, but they come in handy in cases where developers may have forgotten to check in changes to build scripts, etc.

  • cproto - supports `make proto` to automatically update prototype files.
  • sudo - Provide limited super user privileges to specific users
    • Not required, but `sudo make install` is useful for installing to system directories.
    • sudo is also useful for installing packages that are missing.
    • Do not run `make` as the root user for security reasons.

START HERE

This is the starting point and confirms you are located in your home directory

 $ pwd
 /home/<username>

* Trunk Server Build Script

Trunk Build Script

DOWNLOAD

  • Trunk contains the newest features and development for the game
  • Tags is an official & stable release of the game

IMPORTANT - One should be consistent with what they check out; meaning use all trunk server & archetypes & maps or tags/1.60.0 server & archetypes & maps otherwise you run the risk of incompatibilities (broken maps, missing graphics, etc.)

The follow steps will download the necessary files to your computer, which will be used to compile (or build) the server.

Trunk

$ svn co https://svn.code.sf.net/p/crossfire/code/server/trunk server.svn
$ svn co https://svn.code.sf.net/p/crossfire/code/maps/trunk maps.svn
$ svn co https://svn.code.sf.net/p/crossfire/code/arch/trunk arch.svn

Tag

Here's how you download Tag and is using the 1.71.0 release as an example

$ svn co https://svn.code.sf.net/p/crossfire/code/server/tags/1.71.0 server.svn
$ svn co https://svn.code.sf.net/p/crossfire/code/maps/tags/1.71.0 maps.svn
$ svn co https://svn.code.sf.net/p/crossfire/code/arch/tags/1.71.0 arch.svn

SETUP

This confirms that you are still in your home directory

 $ pwd
 /home/<username>

Now change directory (hence the cd) to the directory that contains the server files

 $ cd server.svn

This confirms that you are in the server directory

 $ pwd
 /home/<username>/server.svn

This step “links” two directories to each other which makes the compile process more automated

 $ ln -s /home/<username>/maps.svn maps

This step “links” two directories to each other which makes the compile process more automated and is used by the server once Crossfire server is up and running. This links the server to the map files which you downloaded earlier.

First, create the necessary directory tree for the map files with this command:

 $ sudo mkdir -p /usr/games/crossfire/share/crossfire
 $ sudo chown -R <username>.<username> /usr/games/crossfire/

What that does, is it creates a directory located here: /usr/games/crossfire/share/crossfire and changes the ownership of this directory to your user

Now this step “links” two directories to each other which makes the compile process more automated

 $  ln -s /home/<username>/maps.svn /usr/games/crossfire/share/crossfire/maps

Now change directory (hence the cd) to the directory that contains the library files

 $ cd lib

Double check that you are in the correct directory

 $ pwd
 /home/<username>/server.svn/lib

This step “links” two directories to each other which makes the compile process more automated. This links the arch or archetype files to the server files which you downloaded earlier.

 $ ln -s /home/<username>/arch.svn ./arch

Go back another directory

 $ cd ..

Double check that you are in the correct directory which is the server directory

 $ pwd
 /home/<username>/server.svn

COMPILE

SVN commit (~2007-Mar-30) changed the build process for the server; use the following command in the server root directory:

$ sh autogen.sh && make && sudo make install

autogen.sh script re-creates the configure (./configure) script while the rest of the command starts the compile (build) process. Pass the same options to autogen.sh as you would normally pass to ./configure since autogen.sh calls ./configure. This command requires both autoconf and automake to be installed.

(Otherwise do the following, and look below for optional arguments to autogen.sh) Now you are going to begin the compile process; choose one of the following:

$ ./configure && make && make install

Any missing dependencies, errors or similar problems during the compile process will be listed. Each should be addressed or resolved accordingly.

Optional: If you want to have more useful debugging information in case of crashes, set the CFLAGS environment variable to disable optimization (-O0) and enable debugging (-g): That is a uppercase letter O and a zero

$ CFLAGS="-O0 -g" ./configure && make && make install

Optional: For even more gdb debugging information, add -ggdb3 to the command

$ CFLAGS="-O0 -ggdb3" ./configure && make && make install

Optional: To disable the unit test or check when compiling the server, use ./configure –disable-check

$ ./configure --disable-check && make && make install

Optional: To enforce the unit test or check when compiling the server, use make -k check

$ ./configure && make -k check && make install

LAUNCH

Once the server has been successfully built (aka compiled), you need to launch the Crossfire Server application

Double check that you are in the correct directory which is the server directory

 $ pwd
 /home/<username>/server.svn

Change directory the server directory

$ cd server

Your file directory path should look like this:

 $ pwd
 /home/<username>/server.svn/server

Run this command to launch the server:

$ ./crossfire-server &

What that command will do is run the Crossfire server and return you back to bash or shell prompt

failure to launch

If crossfire-server is unable to locate the maps file it may be because the chown command didn't work. You may see an error like:

[EE] Cannot open /usr/games/crossfire/var/crossfire/clockdata for writing
[EE] Couldn't read regions file from "/usr/games/crossfire/share/crossfire/maps/regions.reg".
[EE] Please check that your maps are correctly installed.

A simple fix is to:

$ sudo chown -R <username>.<username> /usr/games/crossfire/
$ ln -s /home/crossfire/maps.svn /usr/games/crossfire/share/crossfire/maps

Note, great care should be taken in using chown -R as this will change all permissions in the parent directory (e.g. if you “ $ sudo chown -R <username>.<username> /” you will break your linux install's permissions completely)

Crossloop

This might be a good time to setup crossloop.

UPDATE

To update an existing install to the latest svn image;

This confirms that you are still in your home directory

 $ pwd
 /home/<username>

Now change directory (hence the cd) to the directory that contains the server files

 $ cd server.svn

This confirms that you are in the server directory

 $ pwd
 /home/<username>/server.svn

This updates the directory using svn

$ svn update

repeat for

maps.svn arch.svn

and repeat section “COMPILE”

Microsoft Windows Compile Guide

Warning this information may be out of date

Subversion

To access the latest version of crossfire from sourceforge, a Windows compatible tool to access the source files is called tortoisesvn which is available here.

The interface is built into the windows environment, to access the repository create a new folder such as “crossfire files” and right click on this folder. You will see the following option menu now available:

Select “Repo-browser”. When asked, use this URL: https://svn.code.sf.net/p/crossfire/code

After a short time you should now see a window with the current directory structure of crossfire.

You can now start checking out directories you are interested in. Note: that the branches (trunk, stable etc) are within these directories so do not check-out from the root directory unless you want to download _everything_. To checkout a directory simply right click and select checkout:

and then choose where to save the downloaded files:

Requirements

The following tools are used to compile the server:

  • Microsoft Visual Studio 6 (service pack 4 probably). Server has not been tested with other versions.
    • you need it to build common/loader.c and random_maps/reader.c from their respective .l. Syntax is: flex -oloader.c -i loader.l, flex -oreader.c -i -P rm reader.l respectively. The -P rm seems to be required to not have duplicate symbol issues
  • Python to build the Python plugin. Any version starting from 2.3 should do the trick, if not report a bug please. 1.50 has been tested with Python 2.6.5 from Python.org, direct link (MSI installer)
  • if you want metaserver2 support, you'll need:
    • libcurl, from http://curl.haxx.se/. You probably want this file (no SSL support, none needed a priori).
    • pthread, obtained from http://www.sourceware.org/pthreads-win32/. Tested with pthreads-w32-2-8-0-release.exe
    • zlib, file zlib1-dll.zip from GNU Win32 (direct link)
    • copy the following files to the directory you'll run Crossfire from: pthreadVC2.dll, zlib1.dll, libcurl.dll
    • link the executable to libcurl.lib and pthreadVC2.lib (project settings → link → general → object/library modules)
  • to build the installer, you need NSIS, and PERL (for maps installer).
  • to build archetypes, you need PERL
  • once you got the server sources, open a command prompt, go to make_win32 directory, run the installwin32.bat file. It will create required directories

The following tools are used to compile the client:

  • GTK. An installer with all required dependencies can be found at the Glade/GTK+ project. Warning: you'll need to add ~10 directories to include list, and rename some files around (like copy libpng.lib to png.lib). Don't ask why here, ask Glade/GTK+ project instead :)
  • current SVN (end of 2006) is somewhat broken, and requires some tweaking to build (need to undef HAVE_SDL, comment out lines, add files, and such). That may be fixed or not eventually.
  • if you want metaserver2 support, follow the same instructions as for the server.

Cross-Compiling

It may be possible to cross-compile Windows binaries from Unix.

wiki/data/pages/server/server_compiling.txt · Last modified: 2014/09/11 01:54 (external edit)