Compiling

This page contains help on compiling NetHack from source.

On Windows
This was tested on: - Win2k with MinGW-5.0.3, - WinXP with MinGW-5.1.1,


 * Download NetHack's sources from http://nethack.org/v343/download-src.html


 * Download MinGW from http://sourceforge.net/project/showfiles.php?group_id=2435 (You want the MinGW-X.Y.Z.exe installer)


 * Install MinGW. If you use the 'minimal' installation, remember to also select the optional 'MinGW make' -component, so it gets installed. Use, say, C:\mingw\ as the path to install to.


 * Unpack the NetHack source package somewhere, say, c:\nh343\. After unpacking, that directory should contain several subdirectories, such as src, include, win and sys. You will need WinZip or some other utility that can uncompress the package.


 * Go to c:\nh343\sys\winnt\ and run nhsetup.bat

to GRAPHICAL=Y
 * If you want to run the graphical windows GUI, edit c:\nh343\src\makefile.gcc</tt> and change the line
 * 1) GRAPHICAL=Y

PATH=c:\mingw\bin cd src mingw32-make -f makefile.gcc install
 * Go to c:\nh343\</tt> and create a new file called 'install.bat'</tt> with the following contents:


 * Run the install.bat</tt> you just created. This takes about thirty seconds.


 * The NetHack binary should now be in c:\nh343\binary\</tt>


 * If you want to patch your NetHack, you should next see the article on patching.

TTY
The following compiles the TTY-version of NetHack, with all the default settings.


 * Download NetHack's sources from http://nethack.org/v343/download-src.html


 * Make sure you have the development packages for ncurses installed. On debian these are called libncurses5-dev.


 * Open a terminal, and cd</tt> to the directory where you downloaded the source package to.

tar xvzf nethack-343-src.tgz cd nethack-3.4.3
 * Unpack the NetHack sources and move to the NetHack source root directory:

sh sys/unix/setup.sh x
 * Execute the script that moves the Makefiles to the correct places:

/* #define LINUX */ to
 * Edit include/unixconf.h</tt> by changing
 * 1) define LINUX

and uncommenting this line so it looks like WINTTYLIB = -lncurses
 * Edit src/Makefile</tt> by commenting the following like so
 * 1) WINTTYLIB = -ltermlib


 * Typing make</tt> in the NetHack source root dir should compile the binary executable.


 * To install NetHack to /usr/games/</tt>, type make install</tt> while you're logged in as root. If you want to change the installation directory, you need to edit the top Makefile.


 * For more information about compiling NetHack, see the sys/unix/Install.unx</tt> text file.


 * If you want to patch your NetHack, you should next see the article on patching.

X11
The following compiles the X11 windowport with default settings. First follow the instructions in the TTY section, then continue this.


 * Make sure you have the X11 Athena Widget libraries and headers installed. On Debian these are libxaw, libxaw-dev and libxaw-headers.

/* #define X11_GRAPHICS */ to
 * Edit include/config.h</tt> by changing
 * 1) define X11_GRAPHICS

and /* # define USE_XPM */ to
 * 1) define USE_XPM


 * Edit src/Makefile</tt>:
 * add $(WINX11SRC)</tt> to WINSRC</tt>, <tt>$(WINX11OBJ)</tt> to <tt>WINOBJ</tt> and <tt>$(WINX11LIB)</tt> to <tt>WINLIB</tt>.
 * Change <tt>WINX11LIB</tt> so that it has <tt>-lXaw -lXmu -lXext -lXt -lXpm -lX11 -lm</tt>
 * At least on debian, <tt>WINX11LIB</tt> also needs <tt>-L/usr/X11R6/lib</tt>


 * Edit <tt>Makefile</tt> so that <tt>VARDATND</tt> includes <tt>x11tiles NetHack.ad pet_mark.xbm rip.xpm</tt>


 * Type <tt>make</tt> in the NetHack source root dir.


 * To install NetHack to <tt>/usr/games/</tt>, type <tt>make install</tt> while you're logged in as root. If you want to change the installation directory, you need to edit the top Makefile.


 * For more information about compiling NetHack, see the <tt>sys/unix/Install.unx</tt> text file. For X11 compilation, see <tt>win/X11/Install.X11</tt>


 * If you want to patch your NetHack, you should next see the article on patching.


 * If you want to use tiles on X11, or change the window colors, see the article on X11 configuration.