User:Jamesr/Source Code Compiling

From SRB2 Wiki
(Redirected from User:Jamesr/Makefile2)
Jump to navigation Jump to search

The Makefile is the preferred method of compiling SRB2, except on macOS. It has been tested on Windows and Linux.

Prerequisites

Windows

On Windows, you must install MinGW. This guide uses the MSYS2 method.

Selecting the 32-bit MSYS2 shortcut.

Follow the installation instructions at msys2.org

Note

You must open the 32-bit shortcut to be able to use 32-bit (i686) programs.

After you've followed the steps listed there, close the MSYS2 window and open its 32-bit shortcut. Then enter these commands into the new window.

pacman -S git mingw-w64-i686-make mingw-w64-i686-gcc mingw-w64-i686-nasm

This will install Git, for downloading the source code, and Make, GCC and NASM for compiling the source code.

Linux

Note

SRB2 Kart does not use libopenmpt.

If you are using a 32-bit system, then you must also install NASM, or disable assembler source code.

Ubuntu

Enter the following command in a terminal to install the tools and dependencies required to build SRB2.

sudo apt-get install build-essential libpng-dev zlib1g-dev libsdl2-dev libsdl2-mixer-dev libgme-dev libopenmpt-dev libcurl4-openssl-dev

To install NASM:

sudo apt-get install nasm

Arch Linux

sudo pacman -S base-devel libpng zlib sdl2 sdl2_mixer libgme curl

libopenmpt is available as an AUR package.

To install NASM:

sudo pacman -S nasm

Download the Source Code

Find a suitable folder on your hard drive. Git will download the source code into a subfolder there.

Note

Windows path names under MSYS2 follow a different convention than that of most programs (such as Windows Explorer.) For example, if the path is C:\Users\King\My Documents, then use /c/Users/King/My Documents under MSYS2.

Enter this command to go there.

cd '/c/Users/King/My Documents'
Git Clone URLs
Codebase git.do.srb2.org (preferred) GitHub
SRB2 https://git.do.srb2.org/STJr/SRB2.git https://github.com/STJr/SRB2.git
SRB2 Kart https://git.do.srb2.org/KartKrew/Kart-Public.git https://github.com/STJr/Kart-Public.git

Enter this command to download the source code. You may substitute one of the above URLs.

git clone https://git.do.srb2.org/STJr/SRB2.git

Compile the Source Code

Note

The SRB2 Kart codebase is not up to date with these instructions at the time of writing (16th of June 2021).

Enter the subfolder in which Git downloaded the source code.

cd SRB2

On Windows, use this command.

mingw32-make.exe CC=i686-w64-mingw32-gcc

On Linux, this one.

make
Note
To compile without assembler source code (applicable on

32-bit systems), add NOASM=1.

For example:

make NOASM=1
Note
If you're using a multi-core processor, you may try

adding -j, followed by the number of cores, to compile multiple files at once. This speeds up building significantly.

For example, on a four core processor:

mingw32-make.exe CC=i686-w64-mingw32-gcc -j 4

Once the executable is ready, a line like the following will be printed, alerting you to its location.

=== Build is done, look for lsdl2srb2 at /home/james/proj/srb2/srb2/bin ===