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 2, libcurl, Lua, Freetype, Fontconfig and ENet. Also the pkg-config utility must be available (at build time). On Debian systems the following packages will satisfy the requirements:

(If you only want to build the server, and not the game itself, then sdl2, freetype and fontconfig can be omitted.)

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 Community Edition for free from Microsoft.)

Before you start, note that Knights is currently using vcpkg for dependency management, so the first thing to do is install vcpkg on your local machine. Follow step 1 ("Set up vcpkg") from Microsoft's Tutorial: Install and use packages with MSBuild in Visual Studio.

Next, obtain the Knights source code, either by downloading the latest source release from the download page, or by cloning the Git repository.

Then, navigate to the "msvc" folder within the Knights source code directory, and open Knights.sln. Then simply do "Build Solution" which will build the Knights game and server executables. (The first build might take a bit longer than usual, because vcpkg will automatically download and unpack all required dependencies, such as Boost, SDL2 and Libcurl.) Both Release and Debug builds are available.

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 6\iscc" installer.iss

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

Previous Contents Next
Running a Server Copyright and Contact Details