Posted by: duskfire | August 3, 2013

Compiling Nethack 4

Nethack is a classic dungeon crawler (specifically in the “rogue-like” genre of games). You choose from one of 14 character types, each with different starting equipment and abilities, and work your way through a harsh dungeon fighting off monsters, keeping your pet(s) fed and friendly, and bargaining with shopkeepers, in search of better armor, weapons, and special equipment so that you can eventually obtain the Amulet of Yendor in the bottom levels, work your way back to the top, and offer it up to your deity (and so win the game).  If you die, you don’t get to reload – you must start from the beginning, with all the dungeon levels created anew.

It’s been ten years since the official version has had a new release, and several fans have created new variants to make the game still fun and different for players. Nethack4 is one such variant, which seeks to stick very close to the original gameplay, but adds built-in play over a network and many improvements in interface to lessen the more aggravating elements of the game.

Samurai are one of the easier classes...

A Samurai is one of the easier classes…

[EDIT, 9/20/13: the compiling instructions below are obsolete. Nethack4 no longer uses cmake to build, it only uses aimake. Check the README for current build instructions once you have unzipped the latest source archive.]

Getting Nethack 4 compiled so it runs on Linux is extremely simple, and you should definitely do it if you are a Nethack aficionado and have a machine that runs Linux. At the present time, Nethack 4 can only be played in one of two ways – (1) on their public server, or (2) by compiling the source code on Linux for local play. No Windows version exists, and so far attempts to compile on Windows have not met with success.

I’m running Crunchbang Linux 11 using Debian testing/Jessie sources. Ubuntu and Mint Linux users should find the files below listed in their repos. If you run Fedora, openSUSE, Arch, or some other distro, you’ll need to find the equivalent files in your repository.

Step 1: install the following files if they aren’t on your system already.

– cmake and cmake-data

– libjansson4

– libncursesw5

– postgresql-server-all (also pulls in 4 dependencies)

– build-essential

(the FAQ for Nethack 4 mentions AIMake as an alternative to cmake, but it’s still in beta and I recommend cmake at this time)

Step 1.5 if “flex” and “bison are not installed on your system at this point, install them as well.

Step 2: Navigate to the Github repository page for Nethack4 and download the “nicehack” file on the right hand side. It’s directly under “Source tree” and says “Download nicehack as tar.gz”.

Step 3: in a terminal, cd to the location you downloaded it to and execute the following command: tar xvfz nicehack

Step 4: cd into the newly created directory.

Step 5:  Execute the following commands for a regular installation (from the Nethack4 FAQ):

mkdir build

cd build

cmake ..


make install (using sudo for root powers; installs into $HOME/nethack4 if you didn’t edit the target paths)

and you’re done!

(EDIT 8/12/13:  I discovered that the above will set the score list (the “record” file) to root owner with no write permission for anyone else. Go into the /nethack4/nethack4-data/ directory and change the permissions for the file, otherwise your scores for play will not be kept at all.)

When running the game, I recommend that you open the terminal up to maximum size beforehand.

Some other advantages of Nethack4 over vanilla Nethack are –

1. If you have no number pad the game lets you use arrow keys for regular up/down/right/left movement in addition to hjkl.

2. You have the option to view your previous games move by move

Died after bashing down a shopkeeper's door.

Died after bashing down a shopkeeper’s door.

3. Easy to configure options for play that persist between games.


4. Your inventory is shown at all times.

5. Death by typos are reduced – this version asks to confirm if you are attempting to eat tainted food, poisonous food, or when already satiated, for instance.

6. Options menu allows you to rebind keys to different commands.

7. There is auto-explore, and you can #annotate levels.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: