Skip to content

Compilation guide

Ensiform edited this page Aug 20, 2014 · 54 revisions

The source code for OpenJK, which includes Jedi Outcast and Jedi Academy, can be downloaded from the git repository git@github.com:JACoders/OpenJK.git. 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.

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.

  1. Get CMake for your platform. See here for steps on installing CMake on Windows
  2. Get the dependencies. In Windows, they're included (although external version of the libraries can be used.) Otherwise, consult the Readme for a list of required libraries, like zlib and OpenAL.
  3. Go to the folder where the OpenJK source code is located, and create a build folder.
  4. In the build folder, run cmake ... 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 typing cmake -h.
  5. The generated project/makefile can be found in the build directory.

Linux/Mac OS X CMake notes

  • Building on Linux or Mac OS X requires SDL2.
  • If you wish to build on 64-bit Linux, you should force it to build 32-bit for now, 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 OpenJK.sln file in the build 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>/.

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!

Linux/Mac OS X

  • Run make from the build folder.
  • Built files can be found in the same folder?

Ubuntu and Debian 64-bit notes

You will need the following packages to be installed in addition to those mentioned in the guide below. Please note that X.Org -dev packages are not multiarch compatible at this moment. (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689088)

sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.8-base:i386 libstdc++5:i386 libstdc++6:i386 gcc-multilib g++-multilib libopenal-dev:i386 libsdl2-dev libsdl2-2.0-0:i386 ia32-libs

Ubuntu and Debian 32-bit step-by-step

Note: If you're running a 64-bit system, setting up the proper 32-bit dependencies and adding the 32-bit build flags can be messy. If possible, I recommend setting up a virtual machine with a 32-bit version of the distro you're running and using that to build.

1. Install OpenJK dependencies

$ sudo apt-get install build-essential cmake git libopenal-dev zlib1g-dev libpng12-dev

From here on, we'll assume you are in your 'projects' directory.

2. Install SDL2 and its development files

SDL2 packages are available in Debian testing (jessie) and Ubuntu 13.10 (saucy), and for earlier Ubuntu releases from the Mir staging PPA.

Adding the PPA on Ubuntu 12.04 LTS, 12.10, and 13.04:

$ sudo add-apt-repository ppa:mir-team/staging
$ sudo apt-get update

Installing the SDL2 development package:

$ sudo apt-get install libsdl2-dev

Alternatively, you can build SDL2 from source. Building from source works with all Debian-based distros.
To do this, first install mercurial and the SDL2 dependencies

$ sudo apt-get install mercurial debhelper dh-autoreconf libasound2-dev libgl1-mesa-dev libpulse-dev libudev-dev libdbus-1-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev

clone the SDL2 repository, build it and install it:

$ hg clone http://hg.libsdl.org/SDL SDL2
$ cd SDL2
$ mkdir build && cd build
$ ../configure
$ make && sudo make install

3. Clone the OpenJK repository and create build files

$ git clone https://github.com/JACoders/OpenJK OpenJK
$ cd OpenJK
$ mkdir build && cd build

Run cmake to generate your makefiles and select which components to build (e.g. SP engine, MP engine, MP dedicated server)

$ cmake -G "Unix Makefiles" -i ../

Enter ON or OFF to the prompts (they default to ON so you can just hit Enter at each prompt to build everything). This will produce a makefile.
To compile, run make -jX, where X is the number of cores/threads your computer supports. For instance, on a quad-core i7 with hyper threading, enter -j8.

$ make -j8

This should build everything.
Move the compiled .so files and the .i386/.x86_64 binaries to a folder with your JKA base folder, move all the .so's except rd-vanilla.so into base, and launch the game with one of the .i386/.x86_64 binaries.
If you set the install path in CMake, you could use:

$ make install

If you were using a virtual machine to compile, copy the compiled .so's and .i386/.x86_64's out of the VM to your native OS or to another machine running Linux.
Virtual machines almost always lack the graphics drivers required to play the game directly.

Clone this wiki locally