Previous | Contents | Next

## Appendix A: Building/Installing from Source

This Appendix gives information on how to build and install Knights from the source code.

### Linux

For Linux a Makefile is provided. Most users should just be able to type make followed by make install to build and install respectively. After installing, type knights to run the game.

Before compiling, make sure you have the necessary dependencies installed. The game requires Boost, SDL, libcurl, Freetype and Fontconfig. On Debian systems the following packages will satisfy the requirements:

- libboost-dev
- libboost-filesystem-dev
- libboost-system-dev
- libboost-thread-dev
- libsdl-dev
- libcurl4-openssl-dev or libcurl4-gnutls-dev
- libfreetype6-dev
- libfontconfig-dev

(If you only want to build the server, and not the game itself, then only Boost and libcurl are needed.)

#### Troubleshooting

- On some Linux distributions you may get undefined references to "clock_gettime@@GLIBC_2.2.5" or similar. To fix this, append "-lrt" (without the quotes) to the BOOST_LIBS line in the Knights Makefile.
- If you get Boost related errors, check that you have at least version 1.48 of Boost, and that you have all the relevant Boost packages installed. Also, depending on your exact Linux distribution you might need to edit some of the Makefile options – see comments at the top of the Makefile for details.

#### More Details

You can install only parts of the game by using the following:

- make install_knights – install only the game (and its data files)
- make install_server – install only the server (and its data files)
- make install_docs – install only the documentation files.

By default the game installs the "knights" and "knights_server" executables to /usr/local/bin/, data files to /usr/local/share/knights/, and documentation files to /usr/local/share/doc/knights/. The default install directory can be changed by setting the PREFIX variable, e.g. to install in your home directory use "make PREFIX=$HOME" and "make install PREFIX=$HOME". (The PREFIX should agree between the make and make install commands, otherwise the game will not work!)

For finer control of installation directories, use the following variables:

- BIN_DIR: location of the Knights binary (default: $(PREFIX)/bin)
- DATA_DIR: location of the Knights data files (default: $(PREFIX)/share/knights)
- DOC_DIR: location of the documentation files (default: $(PREFIX)/share/doc/knights)
- KNIGHTS_BINARY_NAME: name of the Knights executable (default: knights)
- SERVER_BINARY_NAME: name of the server executable (default: knights_server)

It is possible to build a version without sound support by editing the Makefile and adding "-DDISABLE_SOUND" to the CPPFLAGS. This might be useful if sound doesn't work on your system for some reason.

The Makefile also supports "make uninstall" (but make sure you pass the correct PREFIX or DIR variables, e.g. "make uninstall PREFIX=$HOME", if you changed these from their default values).

If you are developing, you may like to know that the Makefile is generated automatically from Visual Studio project files (see makemakefile.py in the python directory). The Makefile uses the "Advanced Auto-Dependency Generation" technique described here: http://web.archive.org/web/20080123214633/make.paulandlesley.org/autodep.html.

### Windows

Most Windows users will use the pre-packaged installer, however if you want to try building the game from source code, then read on.

I will assume that you are building with Visual Studio. (You can get the Visual Studio Express Edition for free from Microsoft.)

The first step is to download the source code archive from the Knights website and unpack it to a directory of your choice. Then navigate to the "msvc" folder and open the Knights.sln file. Then simply do "Build Solution" which will build the Knights game and server executables.

Knights uses NuGet for dependency management, so the first time you build, Visual Studio will automatically download all required dependencies (Boost, SDL, etc.) and install them into the solution directory. The only thing you might need to do is give consent for this to happen: check that "Tools → Options → Package Manager → Allow NuGet to download missing packages" is enabled.

To run the game from within the IDE, you will need to do the following:

1. Right-click on KnightsMain and choose "Set as Startup Project".
2. Right-click on KnightsMain, choose "Properties", go to "Configuration Properties → Debugging → Command Arguments", and enter "-d $(ProjectDir)\..\..\knights_data" (without the quotes).
3. Now you can just press F5 to run the game.

You can run the command-line server by setting KnightsSvrMain as the startup project.

If you want to build the installer you must install Inno Setup. Then open a command prompt, cd to the Knights source directory and issue the following command:

`"c:\program files (x86)\inno setup 5\iscc" installer.iss`

This will make an "Output" directory and build the Knights installer there.

#### Known Issues

Currently the Debug build of Knights only works on Windows 8. This is due to a problem with the zlib NuGet package and is beyond my control. The Release build works fine on all versions of Windows though.

Previous | Contents | Next
Running a Server |  | Copyright and Contact Details