Outgun / Documentation / Installing a compiler and libraries for Outgun

Installing a compiler and libraries for Outgun

This page attempts to provide a step by step guide to installing a compiler and the libraries needed, so you can compile Outgun from the sources. If you aren’t familiar with the command line interface, you’ll have to consult Google (I didn’t find a good tutorial to that for you, sorry) and prepare for a rough ride.

Contents

Overview

No matter what system you’re installing for (MinGW optionally with Dev-C++, or Linux), with Allegro there comes a more detailed guide to installing both MinGW and Allegro. Look at allegro\docs\build\mingw32.txt or allegro/docs/build/linux.txt.

There might be some inadequacies and pure errors on this page. I’m sorry I can’t test it out every time something is modified. If you’re having problems, please contact Nix, and I’ll try and advise, and correct this document. In fact, that’s how this page got created. Thanks ThOR27!

Library dependencies

ComponentFunctionLinuxWindows
MinGWcompilerneeded
Pthreadsthread libraryneeded
Allegrogame libraryneeded for clientneeded
HawkNLnetwork libraryneededneeded

Notes for Linux installation

Installing the libraries for Linux is more straightforward, since the GNU C++ compiler and a threads implementation are already installed (if not, you’re in trouble). You can skip to installing Allegro and you don’t need the DirectX package for it. If you only want to compile the dedicated server only version, you don’t even need Allegro.

You should still check the output of “g++ -v” to make sure you aren’t using GCC 3.3.3 (at least the Redhat version, which is the default in Fedora Core 2, has a nasty bug that Outgun doesn’t have workarounds for). In that case, or if your compiler is very old (older than 3.0.0), see installing GCC, but be prepared for some problems if you overwrite your old compiler. It you are a novice, it is safer to install a whole new Linux distribution, but you might not want to do that.

If you have root access and are OK with default installations for all components, you can use the compile.sh script provided with Outgun, to automate all the steps of this guide.

MinGW (skip this for Linux)

MinGW is the Windows compiler used to compile the libraries and finally Outgun. Because of thread safety issues in the C++ STL, most versions of MinGW compile an Outgun that will crash randomly. It has been reported that the problems are fixed in MinGW GCC 4.2.1, but we haven’t tested that yet. Try downloading the newest version of the packages gcc-core, gcc-g++, mingw-runtime, w32api, binutils, and mingw32-make, and ask for help if you hit problems. It is likely that something in this guide doesn’t exactly match the demands of the new versions. You will need a decompressor capable of handling .tar.gz files, for example the open source 7-zip.

If you don’t know how to set environment variables or are having other trouble installing MinGW, get Allegro and read allegro\docs\build\mingw32.txt.

  1. Install by creating a new directory (for example, C:\MinGW), and extracting all the MinGW packages directly to that directory. mingw32-make.exe is an installer; extract it by executing it, and choose the new MinGW directory for it to be installed in.
  2. Add to path [your MinGW dir]\bin (for example, if you installed to C:\MinGW, and the environment variable path is currently set to C:\something, change it to C:\something;C:\MinGW\bin).
  3. Add the environment variable MINGDIR=[your MinGW dir].
  4. Reboot or otherwise make sure the new environment settings are set up.
  5. Type “g++ -v”. The last line should be “gcc version 3.4.2 (mingw special)” or similar (actually, the version number should be 4.2.1 or more).

Pthreads (skip this for Linux)

Pthreads-win32 is a Posix threads implementation for Windows. It is used by both HawkNL and Outgun. Here’s a direct link to an installer dated 2005-01-03. Notice that since 1.0.0, Outgun expects for the library name pthreadGC1 instead of pthreadGC which was used in older versions. You can fix this by editing Outgun’s Makefile if you have an older version of Pthreads installed.

  1. Install by executing pthreads-2005-01-03.exe (you may install to any wanted directory).
  2. Edit GNUmakefile: Change the line “MAKE = make” to “MAKE = mingw32-make”. Also, find the line “GC:” and remove “OBJ="$(DLL_OBJS)"” from the next line.
  3. While in the Pthreads directory (with the .c files), type “mingw32-make GC”.
  4. Copy the newly created pthreadGC1.dll to either your upcoming Outgun directory (preferably) or the Windows system directory.
  5. Copy the newly created libpthreadGC1.a to [your MinGW dir]\lib.
  6. Copy pthread.h, sched.h and semaphore.h to [your MinGW dir]\include.

Allegro (skip this for Linux if only building the dedicated server)

Allegro is an all purpose game programming library used by Outgun for graphics, sounds, keyboard input and more. Here’s a direct link to version 4.1.17, which is strongly recommended especially for Linux because of fixes to nasty ALSA sound bugs in the “stable” 4.0.3, and a better keyboard driver. For MinGW you also need the DirectX support package.

For MinGW (Windows)

  1. Unzip dx70_mgw.zip to your MinGW directory overwriting files.
  2. Unzip all4117.zip to any wanted directory.
  3. While in the Allegro directory, type:
    fix mingw32
    mingw32-make
    mingw32-make install

For Linux

If you don’t have root access, see Allegro’s docs/build/unix.txt, it’s complicated.

If you want to get it easy and don’t want Allegro’s sources, you can possibly install it using your favorite package manager. For example in Fedora Core 2, the required package (but currently the bad version) is allegro-devel and can be installed by running (as root) “yum install allegro-devel”. Just make sure you don’t get the buggy version 4.0.3.

  1. Unzip all4117.zip to any wanted directory.
  2. While in the Allegro directory, type:
    chmod +x fix.sh
    ./fix.sh unix
    ./configure
    make
    su -c "make install"

HawkNL

HawkNL is a portable networking library used by Outgun. Here’s a direct link to version 1.68. You might want to download instead the somewhat fixed version by Nix that’s now shipped with Outgun. It closes sockets reliably on Windows 98 SE which the standard version doesn’t do, and avoids an “address already in use” problem in all Windowses, but I can’t guarantee it doesn’t do something bad in exchange. There is also a newer version called 1.7 beta 1 which is supposed to also close sockets correctly, but hasn’t been tested by us.

For MinGW (Windows)

  1. Unzip HawkNL168src.zip to any wanted directory.
  2. If you are installing HawkNL 1.68 and not a newer version, edit src/makefile.mingw: replace “-lpthreadGC” with “-lpthreadGC1”.
  3. While in the src directory (with the .c files), type “mingw32-make -f makefile.mingw”.
  4. Copy the newly created NL.dll to either your Outgun directory or the Windows system directory.
  5. Copy the newly created libNL.a to [your MinGW dir]\lib.
  6. From ..\include, copy nl.h to [your MinGW dir]\include.

For Linux (32-bit only)

If you don’t have root access, you must copy the library and the headers manually. Hope you know how to do that and to compile Outgun with them. See Allegro’s docs/build/unix.txt for some related information.

Users on 64-bit PC platforms (at least) need to notice that official releases of HawkNL fail at runtime when compiled in 64-bit mode. A patched version of HawkNL will be released by us in the near future. In the meantime, you need to use a 32-bit compiler or download the precompiled version instead.

  1. Unzip HawkNL168src.zip to any wanted directory.
  2. Make sure that /usr/local/lib is mentioned in /etc/ld.so.conf, or replace “/usr/local/lib” in HawkNL’s src/makefile.linux with a directory mentioned in /etc/ld.so.conf or with “/usr/lib”. This is where the HawkNL library will be installed.
  3. While in the src directory (with the .c files), type:
    make -f makefile.linux
    su -c "make -f makefile.linux install && /sbin/ldconfig"

Outgun

Now that the compiler and all libraries are installed, it’s time to compile Outgun itself.

The first step only applies to Outgun 0.5.0-E. For later versions, only one make command is needed.

For MinGW (Windows)

  1. While in the src\leetnet directory, type “mingw32-make” (only for Outgun 0.5.0-E).
  2. While in the src directory, type “mingw32-make”.

For Linux

  1. While in the src/leetnet directory, type “make” (only for Outgun 0.5.0-E).
  2. While in the src directory, type “make LINUX=1”.

Starting with Outgun 1.0.4, you shouldn’t need to use LINUX=1. Notice that Outgun requires features of GNU make. If you get weird errors about the Makefile, try replacing make with gmake in the instructions.

Dedicated server only

If you wish to compile a text-mode dedicated server which doesn’t depend on the X window system or Allegro, you should instead type “make outgun-ded tools”, while in the src directory. This is possible starting from Outgun 1.0.4. Older versions either don’t support this at all (pre-1.0.2), still need Allegro (1.0.2), or at least need a directory clean of object files (use make clean), and using “make LINUX=1 DEDICATED_SERVER_ONLY=1” instead (1.0.2 and 1.0.3).


Updated 2008-03-18 – Niko Ritari