[back to main page]

GearHead 1 on Mac OS XGearHead 1 on Mac OS XGearHead 1 on Mac OS XGearHead 2 on Mac OS XGearHead 2 on Mac OS X

GearHead for Unix

GearHead is a great Roguelike Mecha RPG game by Joseph Hewitt. It's open-source, written using cross-platform Pascal code, and can be compiled by FPC. See the official GearHead page, GearHead 1 and GearHead 2 GitHub repositories.


  1. Linux
  2. Mac OS X

1. Linux

We no longer host here GearHead binaries for Linux, because you can get official GH binaries from better places:

For instructions how to compile GearHead yourself, see the description in the GearHead repositories on GitHub.

2. Mac OS X

Compiling for Mac OS X: These are the issues to watch for:

  1. You need to use command-line option -Px86_64 with FPC, to link with 64-bit libraries.

  2. You need to use command-line option -WM10.12 with FPC, to avoid error "ld: warning: object file (/usr/local/lib/libSDLmain.a(SDLMain.o)) was built for newer OSX version (10.12) than being linked (10.5)". It is possible that on different Mac OS X versions you will need to adjust this (it should be synchronized with how HomeBrew compiles SDL libraries).

  3. FPC must be able to find your X server libraries. Enable this by using the


    command-line options. Personally, I found it most comfortable to add this line -Flxxx to the /etc/fpc.cfg file, this way you don't need to repeat these options in all fpc invocations. See also my Castle Game Engine info about Mac OS X for some notes about compiling Mac OS X programs that link to X server.

  4. You need to use {$linklib SDL_image}{$linklib SDL_ttf} in the code. This avoids linking errors that IMG_Load and TTF_xxx stuff cannot be found. Alternatively, this could be done by command-line FPC options -k-lSDL_image -k-lSDL_ttf.

  5. You need to do SetExceptionMask in code, just like OpenGL units are doing. This avoids crashing with "invalid floating point operation" at start.

The issues 1-3 are "peculiarities" of Mac OS X. The issues 4-5 should be fixed in FPC SDL units sources some day (TODO: submit them).

Here's the precise instruction how you can compile and run on Mac OS X:

# Get the code with 2 fixes for Mac OS X.
git clone https://github.com/michaliskambi/gearhead-1

# Compile console version.
fpc gharena.pas -ogharena-console

# Test console version in the Terminal.
# Make sure your terminal window has at least the minimum size (80x25).

# Clean.
rm -f *.ppu *.o

# Install SDL reqiurements using HomeBrew.
brew install sdl sdl_ttf sdl_image

# Compile SDL version.
# About -Px86_64:
#     The architecture (x86_64) must match the architecture
#     of SDL you installed using HomeBrew.
#     It's simplest to just use x86_64 on modern Mac OS X versions.
# About -WM10.12:
#     The libraries you installed using HomeBrew were linked to support
#     only new Mac OS X versions. You need to link your program like this too,
#     otherwise you get error:
#     ld: warning: object file (/usr/local/lib/libSDLmain.a(SDLMain.o)) was built for newer OSX version (10.12) than being linked (10.5)
fpc -Px86_64 -dSDLMODE -WM10.12 gharena.pas

# Test it!

# Troubleshooting: if the application crashes:
# Note that the SDL application clears the console afterwards.
# To see the errors run like this:
./gharena > /tmp/gh-errors.txt 2>&1
cat /tmp/gh-errors.txt

# Now the same for GearHead 2:

git clone https://github.com/michaliskambi/gearhead-2

# Compile and test console version.
fpc -dASCII gearhead2.pas -ogearhead2-console

# Clean, compile and test SDL version.
rm -f *.ppu *.o
fpc -Px86_64 -WM10.12 gearhead2.pas

If you have questions, feel free to contact me (Michalis).

Go to main GearHead page.