PreviousContentsNext

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:

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

Troubleshooting

More Details

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

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:

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: https://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.

PreviousContentsNext
Running a ServerCopyright and Contact Details