Want to know how to compile JKG for Windows or Linux? You're in the right place! (This tutorial is a copy of the one found here.)
The source code for Jedi Knight Galaxies, can be downloaded from the git repository. Alternatively, you can fork our project if you would like to contribute back! Either way, you must adhere to the GNU GPLv2 license, under which the original Jedi Outcast/Jedi Academy source was licensed. This means any changes to the code must be publicly available. We also really appreciate it when you make mention of Jedi Knight Galaxies in your own projects readme/credits/etc. (Please keep in mind assets for JKG are not covered by this license and have their own separate rules.)
We use Git for our software versioning control and you should use it to keep your local repo up to date, and submit new push/pull requests with your changes. Once you've installed Git, you can clone the repo to your local device using either the cmd git clone https://github.com/JKGDevs/JediKnightGalaxies.git
or git clone git@github.com:JKGDevs/JediKnightGalaxies.git
(if using SSH). Before beginning, we recommended first installing JKG on the device from jkgalaxies.net so you have all the assets and an understanding of how the project should look and behave.
Generating project files
We use CMake as our cross-platform makefile generator. This allows us to maintain a single set of project files, and have CMake generate the Visual Studio solution, Makefile, or Xcode project files for us. The following instructions explain how to use CMake and compile the JKG source code for Linux or Windows. We recommend using Microsoft Visual Studio (Community) on Windows to install/use the MSVC compiler. When installing Visual Studio you'll need to select the Desktop development with C++ workload section. Only the core editor, and MSVC v143 (or later version) - VS 2022 C++ component, and the Windows SDK are necessary to be selected to compile JKG. However some other components like C++ Build Insights, Just-In-Time debugger, C++ Profiling, C++ CMake tools, and IntelliCode might be useful for debugging/developing/and testing JKG (but are not necessary).
Visual Studio Installer example:
- Get the dependencies. On Windows, aside from Git and CMake, dependencies are part of Visual Studio's runtime libraries, or they're included in the JKG source code (although external version of the libraries can be used.) Windows users will need to add CMake to the system PATH (the CMake installer should prompt you to do this automatically).
On Ubuntu/Debian based versions of Linux run the following commands in terminal to acquire necessary dependencies:
$ sudo apt update $ sudo apt install build-essential cmake cmake-curses-gui libjpeg-dev libpng-dev zlib1g-dev libsdl2-dev
Otherwise, adapt your distro's package manager to install the following libraries: cmake, libjpeg, libpng, zlib1g, libsdl2, make, gcc, g++, libc, git
Glibc (libc) requires v2.38 (or higher), please note that you can compile it with earlier versions but will likely encounter crashes on earlier versions of glibc. If you are on Windows, manually install CMake and Git or use a package manager. We require CMake v3.12.0 (or higher).
-
On Windows make sure to restart the machine, after installing Visual Studio and CMake before proceeding. After doing so, simply click on
CreateVisualStudio2022Projects.bat
and it will run a script using CMake to generate a Visual Studio solution in the build directory (you can open it by clicking onJedi Knight Galaxies.sln
). -
On Linux, go to the directory where the JKG source code is located, and create a
build
folder (mkdir build
). In thebuild
folder, runcmake ..
the project/make files will now be generated for you for your platform's primary build tool. If you wish to use a different generator to generate different project/makefiles (e.g., generating mingw32 makefiles on Windows), you can specify a generator using the-G
flag:cmake .. -G <generator-name>
. A list of generators can be found by typingcmake -h
.
A GUI console tool is available through the cmake-curses-gui package installed earlier that may be simpler to use than plain cmake, simply doccmake ..
to bring up the interface, there you can more easily toggle options such as the CMAKE_BUILD_TYPE (eg: debug vs release) to configure and generate the makefiles before running make. -
The generated project/makefile can be found in the
build
directory. Change directories to it. -
On Windows open the
Jedi Knight Galaxies.sln
VS Solution file, and then click on Build > Build Solution to compile and generate executable files. -
On Linux from the
build
directory runmake -j x
where x is the number of cores in your system (eg:make -j 12
will use 12 cores to compile). You can specify less cores if you want it to compile with less overall CPU usage, but it will generally scale with the more cores you have. -
Final setup. You've now successfully compiled the project, however there's a few more things to note about setting up the project. The
JKGalaxies
directory contains code-like content (such as lua scripts and json data tables) that should be packaged into a .pk3 and placed in theJKG
directory (this is whatzz_JKG_Assets5.pk3
contains). Additionally the content inJKGServer
should be placed into theJKG
directory. Finally, you'll want to move the executables to their appropriate locations. To make this all easier, look at the scripts available for reference intools
.
The directory structure should look something like this:
<JKGalaxies> jkgalaxies.x86.exe //primary JKG executable (client) jkgalaxiesded.x86.exe //primary JKG executable (server) OpenAL32.dll //open source dll API library for sound rd-galaxies_x86.dll //dll responsible for renderer code SDL2.dll //open source dll library for low level access to peripherals and GPU access. <JKG> cgamex86.dll //dll responsible for cg code (eg: scoreboard) gamex86.dll //contains most of the game's game logic (eg: combat) JKG_Bespin.pk3 //an example map file server.cfg //server configuration file uix86.dll //dll responsible for user interface elements (eg: shop) zz_JKG_Assets1.pk3 //contains model assets (humanoid, map objects etc) zz_JKG_Assets2.pk3 //contains model assets (weapon models) zz_JKG_Assets3.pk3 //contains sound (and some texture) assets zz_JKG_Assets4.pk3 //contains gfx (textures) and efx/shader assets zz_JKG_Assets5.pk3 //contains code-like data assets (constants, cfg, etc) zz_JKG_EXT_Assets0.pk3 //contains 3rd party assets, JKG has permission to use <server> accountlist.json //contains accounts created by the JKG login system ranks.json //contains rank permissions (used by accounts above)
Linux/Mac OS X CMake notes
- Building on Linux or Mac OS X requires SDL2.
-
If you wish to build on 32-bit Linux, you can force it, by adding the CMake flags
-DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_SHARED_LINKER_FLAGS=-m32 -DCMAKE_SIZEOF_VOID_P=4
-
If you wish to build on Mac OS X, you should force it to build 32-bit, by adding to the CMake commands
-DCMAKE_OSX_ARCHITECTURES=i386
Compiling
Compiling the source code depends on the project/makefile generated. Instructions for the main build tool on each supported platform are supplied below.
Windows
-
Open the
Jedi Knight Galaxies.sln
file in thebuild
folder. - Select the build configuration to use (Debug/Release/RelWithDebInfo/MinSizeRel).
- Build the solution.
-
Built files can be found in
build/<project name>/<build configuration>/
.
Linux/Mac OS X
-
Run
make
from thebuild
folder. (Alternatively include the -j with a number of cores to use multiple cores in the build process). - Executables are found in the build directory.
Multiarch builds
If you are attempting to build 32-bit binaries under 64-bit Linux, chances are you will be able to make use of multiarch support in most modern Linux distros. If you are having problems, then we suggest creating a 32-bit chroot and building inside of the chroot.
Launching the game.
At the moment JKG requires several startup arguments to function properly. A typical launch will look something like this:
Windows:
jkgalaxies.x86.exe +set fs_game "JKG" +set fs_cdpath "." +set fs_basepath "C:\Program Files (x86)\Steam\steamapp\Jedi Academy\base\GameData"
or Linux:
#!/bin/sh ./jkgalaxies.x86_64 +set fs_game "JKG" +set fs_cdpath "." +set fs_basepath "/home/username/.local/share/Steam/steamapps/common/Jedi Academy/GameData"
fs_game specifies the mod being run, fs_cdpath specifies where to find JKG's assets, fs_basepath specifies where to find JKA's assets. We recommend setting up a script to make launching the game easier after each compile for testing purposes. You might check the /tools/ directory for examples.
Edited by Futuza
Updated broken image example with new image
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now