Building and Compiling

From Cube Wiki
Jump to: navigation, search

The following are methods to compile Sauerbraten for the three main target OSes (Windows, Linux and Mac OS X).


Windows

Code::Blocks / TDM-GCC

First, install TDM-GCC 64bit version: TDM-GCC (the second link on that page) Then, install Code::Blocks (first windows download link, no need for the packaged mingGW)

Boot up Code Blocks, click "Open An Existing Project", navigate to sauerbraten/src/vcpp/ and select sauerbraten.cbp

In the menu bar click Build, -> Build, and it will compile to your sauerbraten folder. After it is done (you will see blue text saying 0 errors and such) you can run sauerbraten.bat

Code::Blocks / MinGW

Note: the following method does not work with the more recent versions, use tdm gcc 64 bit.

To compile Sauerbraten under Windows, download Code::Blocks and install it. After installation has completed, load up Code::Blocks, go to File > Open. Navigate to "sauerbraten/src/mingw" and select "sauerbraten.cbp". Once the project has loaded, go to Build > Build, and wait patiently for sauerbraten to compile. Once it has finished compiling, you will find the EXE in "sauerbraten/bin" under the name "sauerbraten-mingw.exe". Simply edit your .bat launcher to use this executable instead, and enjoy.

The version of MinGW that ships with Code::Blocks was known to be buggy, especially when compiling Sauerbraten. You should probably obtain the latest version from the Sourceforge download page and install it (to the default location, unless you want to mess with Code::Blocks compiler settings).

Microsoft Visual C++ Express

An alternative method for compiling under Windows is by using Microsoft's Visual C++ 2008 Express Edition. This method is slightly more painful than compiling with Code::Blocks and MinGW, but if you are more familiar with the VC++ line of IDEs, then it can be worth it. To start, navigate to sauerbraten\src\vcpp, double-click on sauerbraten.sln, and click through the process of converting the solution to the latest format. Now, you should have the solution open in front of you. Minimize it (you should still have sauerbraten\src\vcpp open) and open sauerbraten.rc in Notepad or your preferred text editor. The top line should read #include "afxres.h". Now, this header file is deprecated, so change it to the more recent winresrc.h. (Note that you should have the Platform SDK installed, which you probably do if you're developing with VC++; you should have the include directories set up, because that's where the header is.) Save and close. One more thing to go: Right click on sauerbraten in the solution explorer, go to Properties, expand Linker, go to General, and change ..\..\bin\sauerbraten.exe to something like ..\..\bin\sauerbraten-vcpp.exe, since you probably don't want to replace the vanilla Sauerbraten executable. Hit OK. Now you're ready! Hit Build > Build Solution, and wait patiently for it to compile. As above, edit your .bat launcher (or create a new one) to use the executable you compiled. Have fun!

MSYS

Yet another alternative method exists for Windows: that of compiling using the cmd replacement MSYS. Information and download links can be had at MinGW.org. Once you have both MSYS and the MinGW compiler, the compile process is strikingly similar to Linux's: Open up MSYS, cd into Sauerbraten's src directory, and perform, as shown below, the 'make-dance'.


Linux

Provided they have GCC installed (pulled in with the package 'build-essential' on a lot of distributions) and the required SDL development libraries (libsdl-image1.2-dev, libsdl-mixer-1.2-dev), the users of Linux need only perform the usual make-dance. Change into the directory "sauerbraten/src" (in a terminal) and then run

make clean
make
make install

Of course, after this, you need to make sure you run the native_* binaries, not the linux_* binaries! (The sauerbraten_unix script handles this for you.)


Mac OS X

Todo... There is an Xcode project file, or you can use Code::Blocks for Mac.