-
Notifications
You must be signed in to change notification settings - Fork 187
Project Setup (Linux)
Important
Only the server programs can be built and run on Linux. The client and tools currently require Windows to build. Cross-platform support for the client is underway.
A client executable, compiled on Windows, can be run using Proton if you're solely focused on server development.
- Prerequisites
- Fork the Repository
- IDE Setup
- Database Setup
- ODBC Setup
- Server Configuration
- Client Setup
This is the guide for the Linux-based project setup. If you're looking for Windows, see Project Setup (Windows).
You'll need the following to work with the project:
- CLion
- Dependency packages listed below
You'll need the following dependencies installed on your system:
| package | description |
|---|---|
| unixodbc | ODBC tools (like odbcinst) |
| unixodbc-dev | ODBC build headers and libraries |
| msodbcsql | Microsoft MSSQL ODBC driver v18 |
| docker | Docker is an container management platform |
| git | Git is a source code management tool |
Below are the commands for a few popular package managers.
apt (Debian, Ubuntu, others)
sudo apt install unixodbc unixodbc-dev git
sudo ACCEPT_EULA=Y apt install msodbcsql18
pacman (Arch)
sudo pacman -S unixodbc msodbcsql docker git
yay (Arch AUR)
sudo yay -S unixodbc msodbcsql docker git
homebrew (Mac)
brew install unixodbc docker git
brew tap microsoft/mssql-release
brew install msodbcsql18
Fork the Knight Online repository then clone your fork to your machine. If you're unfamiliar with Git, see our Using Git page for help.
Our current IDE recommendation for Linux-based platforms is CLion. This IDE is free for non-commercial use, and this is a non-commercial project. Installation is left to the user to figure out as it varies by distribution.
Once installed, you should see the following welcome screen. Click the "Open" button and select the folder of your git repository (KnightOnline).

CLion should automatically detect the CMake build files used to build the Server projects. You should be able to just accept default configuration for the Debug profile:

It will take a moment for the project indexes and CMake caches to build. You'll know when this is complete when the progress bar in the lower-right goes away:

The CMake build configurations should now be loaded and available in the Run Configurations section (top-right corner of the IDE):

Build and run the servers in the typical order: AIServer > Ebenezer > Aujard > VersionManager
Compiled server files (and configuration) will be written to cmake-build-debug/bin/Debug. Default configuration files will be generated on first run. These do not need to be updated unless you're using an altered ODBC DSN.
If your SQL Server, ODBC, and server configuration files are setup correctly then you should see the program launch after a successful build:

It is recommended to use our docker image and scripts for development on Linux. See the Docker README.MD for guidance.
SQL Server does have support for some Linux distributions. If you want to attempt a manual setup, see SQL Server Manual Setup.
Note that this assumes you've either:
- Successfully started the Docker database container, OR
- Manually restored the database as "KN_online" (if you restored it as something else, be sure to use its new name appropriately).
To find the location of your odbc configuration files, run the following in a terminal:
odbcinst -j
We're interested in location of the driver and system data source configuration files:
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
Edit these files to configure your ODBC connection:
- Edit
odbcinst.iniand ensure that the following driver registration exists (your driver location may vary):
[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.5.so.1.1
UsageCount=1
- Edit
odbc.iniand add the following entry (if you do not already have it). Update the Server and Database information to match your configuration.
[KN_online]
Description = Knight Online SQL Connection
# Driver must match the driver name (in brackets) from odbcinst.ini
Driver = ODBC Driver 18 for SQL Server
Server = localhost,1433
Database = KN_online
Port = 1433
UID = knight
PWD = knight
Encrypt = no
TrustServerCertificate = yes
ConnectionPooling = yes
Using unixodbc's isql tool, we can test our odbc connection to our database. The general syntax for the command is:
isql -v (DSN Name) (User) (Password)
For an out-of-the-box solution, this will typically be:
isql -v KN_online knight knight
This should open an interactive SQL prompt if your connection is successful. You can run a test query here, if desired:
SELECT * FROM TB_USER
Enter quit to close the interactive SQL console.
To connect CLion to your development database, see CLion SQL Client Setup.
The server applications will generate their default configuration the first time they are run. If new configuration is added, the server will add the default value to the file on the next run.
If you feel compelled to change the default configuration, you can edit the .ini file for the application.
Under cmake-build-debug/bin/Debug/:
| Application | Configuration File |
|---|---|
| AIServer | server.ini |
| Ebenezer | gameserver.ini |
| Aujard | Aujard.ini |
| VersionManager | Version.ini |
| ItemManager | ItemManager.ini |
The client does not natively compile/run on Linux as of this writing. This section will show you how to cross-compile the client code into an .exe using the Mingw compiler, then use Wine to run it.
In order to cross compile, you'll need to install the packages that include the mingw compilers x86_64-w64-mingw32-g++
(C++) and x86_64-w64-mingw32-gcc (C) for your distro. You should be able to use the which command to ensure that they
are installed and available on your PATH.
Before configuring a CMake Build Profile for the client, we need to configure a cross-compile Toolchain for it to use.
- Open your IDE Settings with Ctrl+Alt+S
- Search for "toolchains" to filter the list, then select "Toolchains" under "Build, Execution, Deployment".
- Click the + Add icon, and add a new Toolchain configuration as follows:
- Name:
Cross Compile - CMake:
Bundled - Build Tool:
Ninja - C Compiler:
x86_64-w64-mingw32-gcc(usewhichto find the path) - C++ Compiler:
x86_64-w64-mingw32-g++(usewhichto find the path) - Debugger:
Bundled GDB - Click Apply or OK to save
With our Toolchain configured, we can now set up the CMake Client Build Profile.
- Open your IDE Settings with Ctrl+Alt+S
- Search for "cmake" to filter the list, then select "CMake" under "Build, Execution, Deployment"
- Click the + Add icon, and add a new Profile as follows:
- Name:
Debug (Client) - Build type:
Debug - Toolchain:
Cross Compile(or whatever you named it in the previous section) - Generator:
Ninja - CMake Options:
-DCMAKE_SYSTEM_NAME="Windows" -DOPENKO_BUILD_SERVERS=OFF -DCMAKE_BUILD_TYPE=Debug - Build Directory:
cmake-build-debug-client - We keep this separate from the Default/Server build directory (cmake-build-debug) in order to prevent cross-cache contamination. Keep this in mind when looking for build artifacts and setting up run configs.
- Click Apply or OK to save
In order to switch between the Client Build Profile and the Default, use the Profile Dropdown to the left of your run configurations dropdown: 
Our Debug (Client) Profile is only set up to build Warfare. It will not be available if you attempt to switch profiles
while a server application is the selected configuration. CLion should automatically pick the correct profile for Server/Client
based on this. Server applications will be compiled into a native executable, the Client will cross-compile into a Windows executable.
If Client/WarFare does not appear in your run configuration list, right-click on the project-level CMakeLists.txt, and select Reload CMake Project.
In order to run the cross-compiled executable, the run configuration must be updated with a working directory that contains
the client data, and optionally an Options.ini file.
You have two options for this:
- Set up a dedicated directory somewhere with the client data and your configuration.
- Set up under the CMake build directory:
KnightOnline/cmake-build-debug-client/ClientData(Note: you'll need to grab the full absolute path to this folder)
Once you've decided, go to Edit Configurations..., select Client/WarFare, and set the Working Directory appropriately.
You should now be able to build/run the client.
It is possible to debug the cross compiled client using Wine's gdb-server integration, and a CLion remote debugger session.
The setup and operation of this debugging process is non-trival. We're exploring our options for a smoother debugging experience before giving an official recommendation.