Guides:How to compile GearHead

## Compiling GearHead 1

To compile the ASCII (the default) version of GearHead:

1. Download the Gearhead source code from http://sourceforge.net/projects/gearhead/files/ and extract it.

2. Download and install the Free Pascal Compiler from http://www.freepascal.org/.

3. Navigate to the GearHead directory and type "fpc gharena". That should be it.

GearHead takes advantage of many FPC mode features, so if you get strange errors while compiling check to make sure you're in the right mode. The game probably won't compile under Delphi or Borland compatability modes.

Note that there may be problems if compiling for DOS using the FPCv1.0. It seems that DirectoryPresent crashes when used. I'd advise towards compiling for Windows when possible. If you absolutely must compile for DOS, edit the file gears.pp and remove the CheckDirectoryPresent procedure along with the call to it during initialization.

Many thanks to Michalis Kamburelis for helping to make GearHead FPCv2 compatable, and portable across OS's.

### Compiling GearHead 1 with SDL

In addition to the GearHead sources and FreePascal you're going to need the following things:

* The GearHead image archive (http://sourceforge.net/projects/gearhead/files/)
* The SDL, SDL\_TTF, SDL\_Mixer, and SDL\_Image runtimes, available from http://www.libsdl.org/
* Note: If you have an older version of FPC, you will also need JEDI-SDL (SDL bindings for Pascal). Since FPC version 2.2.2 (Ubuntu 9.04 Jaunty and later), most SDL units are included with FPC itself. See http://wiki.lazarus.freepascal.org/FPC\_and\_SDL

To install FreePascal and the SDL libs on Ubuntu or another Debian-based GNU/Linux distribution, enter the following on the command line:

```
sudo aptitude install fpc libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev

```

First things first. Install the compiler and the SDL runtimes. You'll need to compile for either Windows or Linux since AFAIK the package doesn't work in DOS. Install the GH images in your GearHead directory; they should be in a subdirectory called "`Image`".

Finally you should be ready to compile. To link the program with the SDL units, define a "SDLMODE" symbol. This can be done from the command line by using -dSDLMODE when compiling arena:

```
fpc gharena -dSDLMODE

```

## Compiling GearHead 2

You will need the following resources(available at http://sourceforge.net/projects/gearhead2/files/):

* GearHead 2 source archive
* GearHead 2 image pack

The images are not necessary if you choose to compile in ASCII mode.

As above, you will also need:

* FreePascal
* SDL libs themselves (core SDL, SDL\_Image, SDL\_ttf, SDL\_Mixer, SDL\_Net)
* Note: If you have an older version of FPC, you will also need JEDI-SDL (SDL bindings for Pascal). Since FPC version 2.2.2 (Ubuntu 9.04 Jaunty and later), most SDL units are included with FPC itself. See http://wiki.lazarus.freepascal.org/FPC\_and\_SDL

To install these on Ubuntu or another Debian-based GNU/Linux distribution, enter the following on the command line:

```
sudo aptitude install fpc libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev

```

If you have all these resources, navigate to the base directory of wherever you extracted the source and type the following to compile the OpenGL (the default) version of GearHead 2:

```
fpc gearhead

```

For the 2D isometric graphics version, define the CUTE symbol on the command line:

```
fpc -dCUTE gearhead

```

For the ASCII version, define the ASCII symbol on the command line:

```
fpc -dASCII gearhead

```

## Compiling Any GearHead Version Through the FPC IDE

To the right is an image *(not available)* of how how GH1 would look being compiled in FPC 2.4.0 in GUI, on a Windows XP computer. This is using the Integrated Development Environment.

Notice that this is for the ASCII version. The file arena.pas is loaded and is the actively selected object.

Notice that in order to actually compile, it is necessary to go under the **F**ile menu to "**C**hange dir..." and select the folder with the GearHead source. This works for either version. Assuming all the necessary image files are in (as in the earlier command line guides), the game will then compile. Should one want to use SDL for the original, or the isometric/ASCII version for the second, all that is required is to go under **O**ptions->**C**ompiler and add the definition (removing the d) into the Co**n**ditional defines box.