[To the Help Page] [News]

Compile Angband

[Cirith Ungol (10 kByte)] Many people want to create their own versions of Angband and its variants. If you can't compile a new variant for your system you often have to wait some time until some kind soul makes a pre-compiled version available. You wait and wait, and read about all the great features of the new version in rec.games.roguelike.angband. And when the pre-compiled version finally arrives the next version is already available.

I'll try to give a step-by-step guide for compiling Angband on the various platforms and compilers.

I recommend that you use the standard Angband source code for your first attempt. The variants often need some tweaking with the configuration. I'll try to cover them in a later update of this page.

If you have compiled Angband and want to share your knowledge with others, send me an e-mail.


DOS & DJGPP

by Robert Rühlmann, rr9@thangorodrim.net

  1. Install DJGPP:
    Get the freely available DJGPP C Compiler. On the DJGPP-page go to the Zip-Picker. This page helps you decide which ZIP files you need to download and will even try to find a ftp-site near you. Select the Allegro-library under 'Extra Stuff/Toolkits' if you want graphic- and sound-support. Download all files and follow the installation instructions.
  2. Install the source:
    Extract the source code with your favorite archive tool (like WinZip, or untgz.exe).
  3. Install optional files:
    If you want to use graphics, sound, or multiple term windows then download the DOS specific files archive and unzip it into the main directory of the game. Then get the graphics archive and unzip it into the lib/xtra/graf/ folder.
  4. Select the makefile:
    Go to the src-directory and rename 'Makefile.dos' (or 'Makefile.ibm' if you don't want graphics and sound and didn't download the Allegro library) to 'Makefile'.
  5. Compile Angband:
    Run "make install". Angband should now be compiled and installed into the Angband folder.
  6. Run Angband:
    Go back to the Angband folder and run Angband.exe.

Possible problems:


Windows & Borland C++ 5.5 commandline tools

by Robert Ruehlmann

  1. Getting the free commandline tools:
    Download the free Borland commandline tools and follow the installation instructions.
  2. Install the Angband source:
    Extract the source code with your favorite archive tool (like WinZip, or untgz.exe).
  3. Install other required files:
    Get the Windows specific files archive and unzip it into the main directory of the game. Then get the graphics archive and unzip it into the lib/xtra/graf/ folder.
  4. Compile Angband:
    Open a commandline window and go to the src-directory. Run "make -f makefile.bcc install". Angband should now be compiled and installed into the Angband folder.
  5. Run Angband:
    Go back to the Angband-folder and run the Angband.exe.

Possible problems:


Windows & Cygwin

by Robert Ruehlmann

  1. Getting the free Cygwin compiler:
    Download the free Cygwin compiler. It provides a shell interface very similiar to a normal Unix/Linux shell with many useful tools. Install it and start the shell.
  2. Install the Angband source code:
    Extract the source code with "tar -xvzf angband-2.9.3.tar.gz".
  3. Install other required files:
    Get the Windows specific files archive and unzip it into the main directory of the game. Then get the graphics archive and unzip it into the lib/xtra/graf/ folder.
  4. Compile Angband:
    Go to the src-directory and run "make -f makefile.cyg install". Angband should now be compiled and installed into the Angband folder.
  5. Run Angband:
    Go back to the Angband-folder and run the Angband.exe.

Windows & Visual C++

by Paul Murray

To build the windows version your need to grab both the source and an extra archive of windows stuff.

Unpack these two (later versions of Winzip can handle .tar.gz) to c:\, with the 'keep folder names' option on. Copy all the files from "c:\ext-win\src" to "c:\angband-283\src" and move the directory "c:\ext-win\lib\xtra" to be "c:\angband-283\lib\xtra". Finally, copy "c:\ext-win\Angband.ini" to "c:\angband-283\Angband.ini".

Now fire up VC++ (I'm assuming 4.0, but it's pretty similar for 5.0).

Select File->New->Project Workspace. Choose Application, set the Name to angband, and the Directory to "c:\angband-283". Choose Insert->Files Into Project. Change directory to src, shift-select everything from the top down to main.c and click Ok. Do the same again and select main-win.c. Do the same again and select everything from melee.c down. Now choose Build->Build Angband.exe.

It should compile everything fine, but complain about PlaySound when it tries to link it. We sort that out by Build->Settings, choose the Link tab (you might have to scroll the tab listing to the right, it's the one after C/C++) and add 'winmm.lib' to the end of the long list of filenames in Object/Library modules. Click Ok, then do Build->Build Angband.exe again. That should have built fine now.

Go to Explorer, and copy "c:\angband-283\Debug\Angband.exe" to "c:\angband-283\Angband.exe". Open "c:\angband-283\Angband.ini" in NotePad and change the LibPath line to "LibPath=c:\angband-283\lib".

We are almost ready, but we have to create a few missing directories. Create "c:\angband-283\lib\info", "\bone", "\apex", "\save" and "\data".

Then run Angband by double-clicking on it. You may find that the initial screen come up totally blank, but don't panic, choose Window->Font->Term-0 and select one of the font files, and it should all be ok.

I have occasionally had a problem where Angband could not save files. Try this out by creating a new character and using File->Save to try and save him once you are in the town. If it says 'Saving game... failed!' then you have the problem.

The solution is to patch the code slightly. Go to line 564 of the source file 'util.c' (You can open it using the file browser, normally the window on the left of the VC++ screen. Change the line so that it reads exactly:
return (open(buf, O_CREAT | O_EXCL | O_WRONLY | O_BINARY,_S_IWRITE));
Be careful with the brackets!
The go to near the top of the file, around line 14, just under the
#include "angband.h"
line, and add a line:
#include <sys/stat.h>
Now choose Build->Build Angband.exe again, wait for it to build, then move Angband.exe from "c:\angband-283\Debug" to "c:\angband-283"

Try running it again, and you should be able to save just fine. Note that before running you should remove any files from "c:\angband-283\save" and "\apex", as otherwise you would not be able to save a character with the same name as you tried earlier, or have scores in the high score table.

If you want to use graphical tiles, please replace the 'lib\xtra\graf\8x8.bmp' file with a version from another archive. The colors are somehow screwed up in the standard distribution.


Windows & Borland C++

by Roger Browne (with a lot of help from Paul Murray)

To build the windows version you need to grab both the source and an extra archive of windows stuff.

Unpack these two (later versions of Winzip can handle .tar.gz) to c:\, with the 'keep folder names' option on. Copy all the files from "c:\ext-win\src" to "c:\angband-283\src" and move the directory "c:\ext-win\lib\xtra" to be "c:\angband-283\lib\xtra".

Now fire up BC5.

Create a new project with the target wizard, choosing "application", Win32 platform and Gui target model, and angband as the target name.

Set compile options (Messages) to 255 warnings so it will make :)

Add the c:\angband-283\src (or wherever you unpacked the files) to the include directories so bc5 can find the header files.

Set the output dir to c:\angband-283 (or a dir of your choice)

Remove the default nodes in the ide window and add all the .c files in src with the exception of the "MAIN" variations, just add main-win.c for those.

Add the resource node angband.rc

Edit h-config.h to uncomment the #define windows statement.

Add to util.c line around line 12 ..

#include <sys/stat.h>
and around line 560,

change the line

return (open(buf, O_CREAT | O_EXCL | O_WRONLY | O_BINARY));
to this:
return (open(buf, O_CREAT | O_EXCL | O_WRONLY | O_BINARY,S_IWRITE));
Note the similarity to the VC++ directions, the syntax is just slightly different for Borland.

Create these directories if they are missing: "c:\angband-283\lib\info", "\bone", "\apex", "\save" and "\data".

Now run or build all and you should get a target exe named "angband.exe" placed neatly in the dir it should be executed from.

Run angband there if you like, or copy the exe, the angband.ini and the lib directory to a place of your choosing, but remember to edit angband.ini to reflect the proper library path.


Windows & lcc-win32

by Robert Ruehlmann for Angband 3.0.0

  1. Getting the free lcc-win32 compiler:
    Download the compiler and install it.
  2. Install the Angband source:
    Extract the source code with your favorite archive tool (like WinZip, or untgz.exe).
  3. Install other required files:
    Get the Windows specific files archive and unzip it into the main directory of the game. Then get the graphics archive and unzip it into the lib/xtra/graf/ folder.
  4. Create the LCC project:
    Start lcc-win32. Select 'File/New/Project...' from the menu and enter "Angband" as the project name. On the "Definition of a new project" set the working directory to "C:\angband\src" or whereever you extracted the source code to and then select the "Windows executable" option. Press the 'Create' button and answer the question about using the wizard to generate the application skeleton with "no". We want to use the existing Angband source code, so we don't need the skeleton code.
  5. Adding the Angband source files to the project:
    Add all files from birth.c to load.c to the project, then add the "main-win.c" file with the "Add new file..." option and finally the files from melee1.c to z-virt.c. Select "Add new file..." again, and this time select the "Resources" filetype and select the "angband.rc" file. "Add new file..." yet again, set the filetype back to "C sources" and select all files in the lua directory except for tolua.c and tolualua.c. Now we are done on that page and can press the 'ok' button.
  6. Setting various project options:
    On the 'Compiler settings' page append ";c:\angband\src\lua" (modify the path to match your own Angband source installation of course) to the include path. On the 'Linker settings' page change the output filename to "C:\angband" (again - use you own Angband path). Then type "winmm.lib" in the 'Additional files to be included in the link' field. In the 'Debugger settings' you should change the start directory to "C:\angband" (or again use your own path to the Angband directory). The 'Executable to start' should be "C:\angband\angband.exe" (did I already mention change it to your path if necessary?). The settings part is now finished. When asked if you want to "Open ... files?" simply say no.
  7. Compiling:
    Select 'Compiler/Generate Makefile' from the menu and wait for it to finish. Now select 'Compiler/Make' and Angband should be compiled.

Windows & MinGW/MSYS

by Tuomas Härkönen for Angband 3.0.5

  1. Install MinGW and MSYS (both available at http://www.mingw.org/)
  2. Enter the Msys shell/environment
  3. Follow the instructions for compiling with Cygwin verbatim (bar installing Cygwin)
  4. Play

Mac & CodeWarrior

by Darin Takemoto

Available at: http://www2.thecia.net/users/takemoto/angcompile.html

Please note that the guide is a bit old and still refers to the "export.andrew.cmu.edu" FTP server that has been replaced by a new FTP server server.

Linux & GCC

by Robert Ruehlmann

  1. Install the Angband source:
    Extract the source code with "tar -xvzf angband-2.9.3.tar.gz".
  2. Install the graphics files:
    If you want to use graphics under X11 then get the graphics archive and unzip it into the lib/xtra/graf/ folder.
  3. Compile Angband:
    Run "./configure", "make", and "make install" in the Angband directory.
  4. Run Angband:
    Start Angband with "./angband".

Amiga & SAS/C

by Mark Howson

Unpack the source. Most code comes in either .zip or .tgz format; use unzip or untgz, both available from Aminet. Be sure to give both of these utilities plenty of stack (especially untgz, which sometimes seems a little temperamental on my system). Note that .zipped code is usually from DOS machines, which store text in CR/LF format (unlike Amiga's and Unix, which just use LF). To fix this, either do 'unzip -aL' when unpacking, or use a text conversion utility (I use 'Port').

Also note that some of the *.txt files have spaces at the end of lines, and these need to be left alone - some conversion utilities (Port, by default, being one) try to be clever and strip these off. Make sure your chosen utility doesn't do this, or alternatively don't convert the *.txt files - Angband is quite happy with either format, but it saves a few bytes to strip them.

Get the Amiga specific files. Copy 'main-ami.c', 'sound-ami.c', 'sound-ami.h', 'scoptions' and 'smakefile' into the 'src' directory.

Now you need to change the directory structure. The sources tend to come looking like this:

lib  (dir)
  apex (dir)
  bone (dir)
  .
  .
  etc.
src  (dir)

However, the Amiga versions have traditionally used a slightly different format:

apex (dir)
bone (dir)
save (dir)
.
.
src (dir)
So it's a good idea to move the contents of the lib directory to the root directory, and delete the (now empty) 'lib'. Finally, you should customise the main-ami.c file to your requirements. The main-ami.c file provided can work with three versions of Angband; 281, 282 and 283. Any Angband versions previous to this are not supported; however, as far as I know only JAngband uses older Ang code. Set the appropriate options as documented in the code. It's also a good idea to set the 'VERSION' and 'VERPATH' defines at the top of the file.

You're now ready to compile, so type 'cd src', then 'smake'. Compilation should now have started - be patient here, especially with a slow machine. It's a good idea to have optimisation switched off for the first go, as an optimised compile can take ages. Expect times of roughly 10 minutes on an 060/50, over an hour on an 040/25.

After a few minutes staring at a grey screen, you should end up with an 'Angband' executable. Now assign 'Angband:' to the parent directory, and check that your compiled program works.

Once you're satisfied everything works, you ought to recompile Angband with optimisation turned on. So type 'scopts' and flip the 'NoOptimise' gadget to 'Optimise', save and exit. Then 'smake clean', followed by 'smake'. This will take a lot longer; roughly 1.5 hours on an 040/25.

© 1997/98 by Robert Rühlmann, rr9@thangorodrim.net [News] [To the Help Page]