wiki:Compiling

Version 3 (modified by nckmccnnll, 5 months ago) (diff)

Add Windows console compiling instructions

Linux or Unix

If you use Unix, then the best option is to use the ./configure script. This requires a recent version of autoconf (v2.60 or later). If you have downloaded a copy of the source from the main website, it will have this included. However, if you have got the source from git you'll have to create it yourself:

 $ sh autogen.sh

If you're using OpenBSD, you may have to specify which version of automake and autoconf you wish to use, like:

 $ AUTOCONF_VERSION=2.59 AUTOMAKE_VERSION=1.9 ./autogen.sh

If you are using a Debian-based distribution, the following should get you all the packages you need for X11, SDL, and GTK ports:

 $ sudo apt-get install autoconf gcc libc6-dev libncurses5-dev libx11-dev \
             libsdl1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev libsdl-image1.2-dev

If you are using a RedHat/Fedora? based distribution (such as Linpus on an Acer Aspire One) and only want the text based interface you can use:

 $ sudo yum install make gcc ncurses-devel

To get a basic build (X11 + curses), with your home directory as the install target, try:

 $ ./configure --prefix=$HOME
 $ make
 $ make install

If you don't want to install locally, but would rather play from the same directory you compiled the game in, try:

 $ ./configure --with-no-install
 $ make

For help with configure:

 $ ./configure --help

Other settings can be tuned. You can set CC (compiler), CPPFLAGS (preprocessor flags), CFLAGS (compiler flags), LDFLAGS (linker flags), and LIBS (libraries). Configure may modify all but CC. For example:

 $ env CC='cc' CPPFLAGS='-DUSE_HARDCODE' ./configure

For a system wide installation you might want to try something more like:

 $ ./configure --with-setgid=games --with-libpath=/usr/local/games/lib/angband
               --bindir=/usr/local/games
 $ make
 $ su -c "make install"

If you don't have/want autotools, or want to use a frontend not supported by automake, then Makefile.std should work for you,

Notes for Solaris users:

  • Package SUNWgmake may have been installed by default, if so, you can use gnu make (/usr/sfw/bin/gmake). The default Solaris make utilities will give an error.
  • If "gmake install" gives an error, change the "INSTALL =" line of mk/rules.mk to an absolute path.

Windows + Cygwin/MinGW

  1. Get MinGW and MSYS here: http://www.mingw.org/
    1. Try using the automated installer.
    2. Click through the installer, accepting the defaults until you get to "Choose components".
    3. Tick the "MingGW Make" entry.
  2. Enter the shell for your environment (in the case of MinGW, this is the Windows command prompt) and get into the src/ directory of the game.
  3. Run make -f makefile.win. Add " MINGW=yes" to the end of that iff you're using MinGW.

Windows Console using MinGW

(Thanks to Once on the Angband forums for these instructions; read at http://angband.oook.cz/forum/showthread.php?p=133963#post133963)

  1. You need a compiler... I assume that you have installed MingW and the base development libraries. If not, there are posts explaining how to do this in this forum.
  1. Make sure you have the *ncurses* library installed. Contrary to what is written in the Makefile, pdcurses will not be sufficient. You need term.h, which only comes with ncurses. To do that, type mingw-get in a console, then select and install libncurses-dev
  1. Move to the angband/src folder
  1. Modify Makefile.win lines 50 and 51 with the correct install path of ncurses (Yes, the keyword says PDCURSES, but it doesn't matter).
    PDCURSES_INC = C:/MinGW/include/ncurses
    PDCURSES_LIB = C:/MinGW/lib/libncurses.a
    
  1. If you try to compile the console version right now it will fail because a few headers do not exist on Windows. These are the locale stuff, and the sound. We do not need either for this version so we can comment these problems out.
    In main.c
    comment out line 38 "#include "langinfo.h"
    
    lines 467-473
    Comment out the full section "if (setlocale(LC_CTYPE, "")) {..."
    
    In sound-core.c, line 62
    Comment out the line "	{ "win", "Windows sound module", init_sound_win }, "
    
    In main-gcu.c replace line 66
    "_stdcall void Sleep(int);" with "void Sleep(int);"
    
  1. Compile
    mingw32-make -f Makefile.win CONSOLE=yes MINGW=yes
    

Windows + Dev-C++

  1. Get and install DevC++.
  2. Create an empty C project, located in the source directory (you can place it elsewhere but you may need to fiddle about a bit more if you do).
  3. Add every C file in src/, and also everything from the src/win, src/monster, src/object and src/player directories.
  4. Go to Project -> Project Options, and:
    1. In the "General" tab, ensure "Win32 console application" is selected.
    2. On Dev-C++ 4, click on "Browse" under "Icon" and select angband.ico.
    3. In the "Build Options" tab, change the executable output directory to "..\".
  5. For SDL, in the "parameters" tab, add:
    • -lmingw32 -mwindows -DWINDOWS -DUSE_SDL to the compiler options.
    • -lwinmm -lmingw32 -mwindows -lSDL -lSDLmain -lSDL_ttf to the linker options.
  6. For the Windows port, in the "parameters" tab, add:
    • -mwindows -DWINDOWS -I. to the compiler options.
    • -lmingw32 -lwinmm -mwindows to the linker options.
  7. Compile.

Windows + Visual C++

Read src/win/angband_visual_studio_step_by_step.txt included with the source code.

Mac OS X + GCC

  • Install the Apple Developer Tools if you haven't already done so.
  • Compile Angband: In Terminal.app type cd angband/src to get to the Angband source directory. Then type make -f Makefile.osx.
  • If everything compiled, then you should have an 'Angband' application bundle in your 'angband' directory. If you want to distribute a modified version to other players then you can use the 'dist' Makefile target to repackage the game. In Terminal.app type: make -f Makefile.osx dist to create a *.dmg disk-image.

If you are trying to compile a variant that doesn't have OS X support, install subversion/svn and recent versions of autoconf & automake, and follow the UNIX instructions above. The curses version probably won't work properly ("LIGHT_DARK" renders as black on black in Terminal.app), but the X11 version should be adequate.