Compiling

From NetHackWiki
Revision as of 11:59, 10 August 2007 by 1633Hz (talk | contribs) (On Windows: Remedy for specific compiling issue)
Jump to navigation Jump to search

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,

  • 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
  • If you want to run the graphical windows GUI, edit c:\nh343\src\makefile.gcc and change the line
#GRAPHICAL=Y

to

GRAPHICAL=Y

NOTE: The latest MinGW (5.1.3 as of writing) has issues compiling the GUI version of the program. To remedy this, copy rpcndr.h from c:\MinGW\include\ to c:\nh343\include\. Edit c:\nh343\include\rpcndr.h by removing or commenting out line 52: "typedef unsigned char boolean;". This should allow the compile to commence with minimal errors.

  • Go to c:\nh343\ and create a new file called 'install.bat' with the following contents:
PATH=c:\mingw\bin
cd src
mingw32-make -f makefile.gcc install
  • Run the install.bat you just created. This takes about thirty seconds.
  • The NetHack binary should now be in c:\nh343\binary\
  • If you want to patch your NetHack, you should next see the article on patching.

On Linux

TTY

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

  • Make sure you have the development packages for ncurses installed. On debian these are called libncurses5-dev.
  • Open a terminal, and cd to the directory where you downloaded the source package to.
  • Unpack the NetHack sources and move to the NetHack source root directory:
tar xvzf nethack-343-src.tgz
cd nethack-3.4.3
  • Execute the script that moves the Makefiles to the correct places:
sh sys/unix/setup.sh x
  • Edit include/unixconf.h by changing
/* #define LINUX */

to

#define LINUX
  • Edit src/Makefile by commenting the following like so
#WINTTYLIB = -ltermlib

and uncommenting this line so it looks like

WINTTYLIB = -lncurses
  • Typing make in the NetHack source root dir should compile the binary executable.
  • To install NetHack to /usr/games/, type make install 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 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.
  • Edit include/config.h by changing
/* #define X11_GRAPHICS */

to

#define X11_GRAPHICS

and

/* # define USE_XPM */

to

# define USE_XPM
  • Edit src/Makefile:
    • add $(WINX11SRC) to WINSRC, $(WINX11OBJ) to WINOBJ and $(WINX11LIB) to WINLIB.
    • Change WINX11LIB so that it has -lXaw -lXmu -lXext -lXt -lXpm -lX11 -lm
    • At least on debian, WINX11LIB also needs -L/usr/X11R6/lib
  • Edit Makefile so that VARDATND includes x11tiles NetHack.ad pet_mark.xbm rip.xpm
  • Type make in the NetHack source root dir.
  • To install NetHack to /usr/games/, type make install 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 text file. For X11 compilation, see win/X11/Install.X11
  • 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.