A Beginner's Guide to Compiling MAngband From the Source
Written by Murdin with the assistance of Flambard, Jug and Warrior
26th June 2008
Introduction
Running and compiling MAngband on Windows is not difficult when you know how to go about it. Follow these step-by-step instructions and you'll be up and running in no time.
Basics and Installations
We'll be using MinGW and MSYS to compile the client and server. This makes the building process nice and simple. I also recommend a good text editor of your choice that preserves spacing and has line count, but that's optional.
MinGW and MSYS both can be found at http://www.mingw.org
Current direct downloads as of June 26, 2008 are:
MinGW - http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe?modtime=1209244789&big_mirror=1
MSYS - http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe?modtime=1079444447&big_mirror=1
Installation is pretty straightforward as long as you're working with the .exe's. Install MinGW first, remember the directory you installed MinGW to and then start up MSYS. It will launch a command window next. You'll want to answer yes to the first two questions (y, enter). It will then ask you:
"Please answer the following in the form of c:/foo/bar.
Where is your MinGW installation?"
You'll want to respond with the path to the directory you installed MinGW to, but use FORWARD slash ("/") instead of back slash ("\") when writing the path. If you somehow make a mistake here, just uninstall MSYS and reinstall it, no harm done.
This information was paraphrased from http://www.mingw.org/MinGWiki/index.php/Install%20MSYS , please refer to this page if you encounter trouble.
Next you'll want to get the source itself. You've got a few options here, but the dev team prefers to work with subversion to keep things up to date. I recommend Tortoise SVN ( http://tortoisesvn.tigris.org/ ). Download it, integrate it, and set up a folder into which to dump the source.
NOTE Do NOT simply dump this into your MAngband base directory or your root directory. This will cause all kinds of trouble!
You can simply right click inside this folder at this point and select "SVN Checkout...". This'll bring up a window titled "Checkout" with a few fields. First off, it'll ask for the URL of the repository. As of this writing, the current source is located at "http://mangband.org/svn/mangband/branches/version-1_1_2" (without the quotes). Your checkout directory should be the folder your right clicked in, but you can change this if needed to a new directory. It'll create a new one (after asking if you want it to) should you choose one that doesn't exist. Leave the other things alone. At this point, hit the OK button and it'll fetch the source for you, assuming everything was entered correctly. You'll see a log of activity, then when it finishes hit ok. Voila, source is in your folder and we're ready to compile.
Compiling
At this point, go ahead and bring up MSYS, it'll put a shortcut on your desktop by default, I recommend simply using that. You're going to have something akin to the command window for Windows at this point. Navigate to your /src folder using the cd (change directory) command followed by your directory using FORWARD slashes.
Example: "cd c:/Projects/MAngbandSource/src"
Once inside a directory you can simply "cd foldername" if you need to step through things. Now that you're located at your src directory, it should say "User@COMPNAME /c/yourdirectory/src" at your prompt. At this point, all you have to do is type "./configure && make" and it'll compile for you.
It'll take it a minute or two to chew through your source. Some warnings will appear in the log, but if your setup is correct you can safely ignore them. Once it finishes thinking, go ahead and type "make install" and navigate up to your base directory.
Try running your server by starting up mangband.exe.
NOTE This will not work if your .exe's are located in the /src directory. Make sure they're in the base directory.
At this point, run your client and try connecting at the loopback address, (Hit Shift+Q, type in 127.0.0.1 or localhost). If all goes well, you will now have a fully functional server and client ready to play with.
A Word on Network Setup
If you intend to have others play, you're going to want to at least set up port forwarding if you're behind a router. You can define the port in the mangband.cfg file, but by default MAngband uses TCP port 18346. I will not go over how to port forward here, please consult your router's manual or Google for instructions. Also make sure your God ("Gandalf") character is defined before someone else does or you'll be in a world of trouble!
If you'd like to have someone else help you test, simply give them your IP (http://whatsmyip.org) after port forwarding and they should be able to connect.
Have fun!
Advanced Info
Getting SDL library
Download and unpack SDL
- On the SDL Web site (http://www.libsdl.org), go to the download section for the current version (1.2.13 at the moment).
- You're given a choice of Source Code, Runtime Libraries, or Development Libraries. Assuming you want to write programs that use SDL, and you just want to get up and running without being bothered compiling the source code yourself, you need the Development Libraries bit of the page.
- You're installing it under MinGW, so download SDL-devel-1.2.13-mingw32.tar.gz (assuming 1.2.13 is the current version).
- Unzip and unpack that file into a temporary directory on your PC. You can delete the directory when you've finished installing. Let's assume you've unpacked the file into /temp/. You'll need something that can handle .gz and .tar, but that's probably in MinGW/MSYS already. Personally I use WinNavigator which deals with them nicely.
Install SDL files for the compiler
- Find your MinGW directory, the one with the bin, doc, include and lib directories in it. Let's assume it's /mingw/
- Create a new directory to put the SDL header files in: /mingw/include/SDL/
- Copy all files (32 of them in SDL 1.2.13) in /temp/SDL-1.2.13/include/SDL/ to this new directory.
- Copy all files (3 of them in SDL 1.2.13) in /temp/SDL-1.2.13/lib/ to /mingw/lib/
- Find your MSYS directory, the one with the bin, doc, etc, and home directories in it. Let's assume it's /msys/
- Copy the file /temp/SDL-1.2.13/bin/sdl-config to /msys/bin/sdl-config. I chose /msys/bin/ because you can be sure that anything in there will always get executed regardless of which directory you're currently in. When you compile an SDL program you need to execute the file sdl-config on the compilation line (more below).
Copy the SDL DLL and tidy up
- Copy the file /temp/SDL-1.2.13/bin/SDL.dll to c:/WINNT/system32/. As that directory will be in your PATH, it ensures that any SDL program you write will find the DLL and you can keep just one copy on your disk. If your Windows drive is something other than c: or windir is not WINNT, then change accordingly.
- Delete /temp/SDL-1.2.13/
This information was copied from http://www.netadelica.com/coding/sdl/install.html and updated on 4 Feb.2009
Working on autoconf scripts
For that you'll need to get http://freefr.dl.sourceforge.net/sourceforge/mingw/msysDTK-1.0.1.exe and install it into your MSYS directory (Those links become obsolete pretty quickly, refer to MSYS website for latest version).
Thanks go out to Flambard, Jug and Warrior for walking me through the process my first time, and answering my (incessant) questions!