-
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, the following command will download and install the required dependencies:
$ sudo apt-get install libjpeg8-dev libpng12-dev zlib1g-dev libsdl2-dev build-essential
There will be equivalent commands on other Linux distros.
For example on openSUSE you will need:
$ sudo zypper in libjpeg8-devel libpng16-devel zlib-devel libSDL2-devel
Install the dependencies:
$ sudo yum install libjpeg-devel libpng-devel zlib-devel
Run cmake with -i
to select the desired parts of OpenJK to build.
Or when cross-compiling for 32 bit:
$ sudo yum install glibc-devel.i686 libstdc++-devel.i686 libjpeg-turbo-devel.i686 libpng-devel.i686 zlib-devel.i686
Run cmake with -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32
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
.
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 ..
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!