-
Notifications
You must be signed in to change notification settings - Fork 620
Compilation guide
This guide will describe how to install OpenJK (Jedi Academy) and optionally OpenJO (Jedi Outcast) by compiling from this source repository.
Warning: This guide is meant for those with minimal technical expertise, as developer tools are necessary to build OpenJK. If you would like to install OpenJK from pre-built binaries, see Installing OpenJK.
You will need the following applications installed on your system:
- Get the source code.
- Get the dependencies.
- Run CMake to build the project files.
- Open the project files (if necessary), and compile!
The source code for OpenJK, which includes Jedi Outcast and Jedi Academy, can be downloaded from the git repository:
$ git clone https://github.com/JACoders/OpenJK.git openjk
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.
The following libraries are required to build OpenJK:
- libjpeg
- libpng
- zlib
- OpenGL
- OpenAL (Windows only)
- SDL2
For Windows builds, all the dependencies are provided with the source code.
On Debian-based distros (including Ubuntu), the following commands will download and install the required dependencies for the current system:
$ sudo apt-get update
$ sudo apt-get install build-essential cmake libjpeg-dev libpng-dev zlib1g-dev libsdl2-dev
If you intend to cross-compile for 32-bit on a 64-bit system, run the following commands:
$ sudo dpkg --add-architecture i386
$ sudo apt-get update
$ sudo apt-get install build-essential cmake gcc-multilib g++-multilib libjpeg-dev:i386 libpng-dev:i386 zlib1g-dev:i386 libsdl2-dev:i386
On openSUSE, the following commands will download and install the required dependencies for the current system:
$ sudo zypper in cmake make gcc gcc-c++ libjpeg8-devel libpng-devel zlib-devel libSDL2-devel libglvnd-devel
If you intend to cross-compile for 32-bit on a 64-bit system, run the following commands:
$ sudo zypper in cmake make gcc-32bit gcc-c++-32bit libjpeg8-32bit libpng-devel-32bit zlib-devel-32bit libSDL2-devel-32bit libglvnd-32bit libglvnd-devel-32bit
On CentOS 7, the following commands will download and install the required dependencies for the current system (dedicated server and MP libraries only):
$ sudo yum install epel-release
$ sudo yum install cmake3 make gcc gcc-c++ glibc-devel libstdc++-devel libjpeg-turbo-devel libpng-devel zlib-devel
If you intend to cross-compile for 32-bit on a 64-bit system, run the following commands:
$ sudo yum install epel-release
$ sudo yum install cmake3 make gcc gcc-c++ glibc-devel.i686 libstdc++-devel.i686 libjpeg-turbo-devel.i686 libpng-devel.i686 zlib-devel.i686
Run cmake3 with -i
to select the desired parts of OpenJK to build.
We recommend using a package manager similar MacPorts or Homebrew to download and install the dependencies. Using Homebrew, you can use the following command:
$ brew install zlib libjpeg libpng sdl2 --universal
zlib
is installed as part of libpng
.
With MacOS 11 (Big Sur) and on Apple silicon ARM64 processors (like the M1), all native ARM64 code must be signed or the operating system prevents its execution.
You can self-sign the created bundle with the following command:
codesign --force --deep --sign - openjk.aarch64.app
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. CMake can be downloaded from the CMake website, or through your package manager. Instructions for installing CMake can be found here.
There are three ways to run CMake:
This method is recommended for people using Windows, or who are new to CMake.
- Open CMake GUI
- In the "Where is the source code" text box, enter the path to the OpenJK source code.
- Copy and paste the patch into the "Where to build the binaries" text box, and add
/build
at the end of the path. - Click the Configure button at the bottom-left of the window.
- Follow the on-screen instructions. If you don't know which compiler to use, then leave it as default.
- The window should now be filled with some settings. Edit the settings to suit your needs. We highly recommend setting
CMAKE_INSTALL_PREFIX
to JKA'sGameData
folder to make running and testing easier later on. Hovering over each setting will give a description of what it does. - Press the Generate button to generate the project files.
- The project files will be generated in the
build/
folder located in your OpenJK source folder.
This method is recommended for people new to CMake and are comfortable using the terminal. On Linux, the curses GUI for CMake might need to be installed separately. For Debian-based distros, the package can be downloaded by running:
sudo apt-get install cmake-curses-gui
To create the project files:
-
cd
to the OpenJK source folder and runmkdir build
. cd build
-
ccmake ..
(note the double c inccmake
) - You can optionally provide the
-G <generator name>
option to specify what type of project file to generate. For example:ccmake -G Ninja ..
will create project files for the Ninja build system. A list of generators can be found by runningcmake
(single c). - Configure the project (press the C key), and then edit the settings to suit your needs. We highly recommend setting
CMAKE_INSTALL_PREFIX
to JKA'sGameData
folder to make running and testing easier later on. - Generate the project (press the G key).
- Your project files will be created in the
build/
directory. - Exit the GUI by pressing the E key.
If you need to change any settings, run make edit_cache
, and the curses GUI will be shown again. Edit the settings, and generate the project again.
This method is recommended for build scripts such as those used in automated builds or for experienced users who are comfortable with using the terminal, and know the flags to pass to CMake. The following commands will create the build directory, and generate the project files for the default generator. You should edit it for your specific needs.
cd $HOME/openjk
mkdir build
cd build
cmake ..
It is recommended to set the install prefix:
cmake -DCMAKE_INSTALL_PREFIX=/path/to/GameData ..
To cross-compile for 32-bit on a 64-bit system:
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/linux-i686.cmake ..
To build only the dedicated server and MP libraries:
cmake -DBuildMPEngine=OFF -DBuildMPRdVanilla=OFF -DBuildMPCGame=OFF -DBuildMPUI=OFF -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF ..
Note that on CentOS 7, you may need to use cmake3
instead of cmake
.
Compiling the source code depends on the project/makefile generated. Instructions for the main build tool on each supported platform are supplied below.
- Open the
OpenJK.sln
file in thebuild
folder with Visual Studio. - Select the build configuration to use (Debug/Release/RelWithDebInfo/MinSizeRel).
- Build the solution.
- Built files can be found in
build/<project name>/<build configuration>/
.
OpenJK makes use of some standard C/C++ headers which aren't available by default in older versions of Visual Studio. Please make sure you're running the latest version of Visual Studio!
Simply run make
from the build
folder. On multicore CPUs, you can improve the speed of compilation by passing the -j
option: make -jN
, Where N
is the number of cores in your CPU.
This will build all the projects. Individual projects can be built by passing the project names as arguments to make
:
$ make openjk_sp.i386
A list of projects can be found by running make help
.
If you have set CMAKE_INSTALL_PREFIX
correctly, running make install
will copy all the built files into their correct places in your GameData
folder, ready to run and test.
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. This is what we do for our automated builds!
If you set the install prefix as mentioned before, you have already moved the files and can skip to the part where we rename the binaries for use in Steam.
Now that you have built binaries for the game, you can move them to the appropriate places.
- Find your Jedi Academy
GameData
folder. If you're using Steam, it should be in<steam folder>/steamapps/common/Jedi Academy/GameData
. - Delete all files currently in this folder with the exception of
SDL2.dll
,version.inf
,OpenAL32.dll
, and thebase
folder. (Alternatively, move them to some other place (such as a subfolder, like_original_files
) in case you need to restore the original Jedi Academy binaries). - Move all the folders generated by compiling in the previous step to this folder. This should include files like
openjk.ARCH
,openjk_sp.ARCH
,jagamex86.dll/so
, etc. - Rename
openjk.ARCH(.exe)
tojamp(.exe)
- Rename
openjk_sp.ARCH(.exe)
tojasp(.exe)
- You're done! You can now launch OpenJK singleplayer by running
jasp
, or multiplayer by runningjamp
!
Some users wish to compile OpenJO (Jedi Outcast) instead of just Jedi Academy. Due to possible bugs and lack of support, OpenJO compilation is disabled by default. Additionally, there is no multiplayer OpenJO build support at this time. To enable OpenJO compilation, follow these steps:
- Edit CMakeLists.txt in the repository directory.
- Change the
BuildJK2SPEngine
,BuildJK2SPGame
, andBuildJK2SPRdVanilla
options to ON. - Follow the 'Getting the Dependencies', 'Generating Project Files', 'Compiling', and 'Installing' sections above.
- In your Jedi Outcast
GameData
folder, delete/move all existing files except for thebase
folder andversion.inf
. - Copy the following files from the Jedi Academy
GameData
to the Jedi OutcastGameData
:
-
cgamex86.dll/so
,uix86.dll/so
, -
SDL2.dll/so
,OpenAL32.dll/so
, -
jospgamex86.dll/so
,rdjosp-vanilla_x86.dll/so
- Copy
openjo_sp(.exe)
from the Jedi AcademyGameData
to the Jedi OutcastGameData
and rename it tojk2sp(.exe)
.