From BZFlagWiki
Revision as of 19:36, 28 March 2010 by Yassen (Talk | contribs) (2.99.x: Update DirectX SDK Version)

Jump to: navigation, search


Compiling BZFlag is the act of taking the raw source codes for the game and using tools to build an executable application(s) for a target system.

Source Code

In order to compile a user must have his or her own copy of the Source Code. The code can be obtained from a source archive from the Download page, or from the BZFlag Subversion server.

Readme Files

Users should always read the README files for the appropriate operating system. These files are located in the root directory of the source code tree.


BZFlag is capable of being built on a number of compilers. The compiler used will depend in some way on the operating system of the computer doing the build.

  • Linux and BSD computers use the GCC compiler.
  • Macintosh computers use the XCode compiler (or gcc, see notes).
  • Windows computers can use the Visual C++ compiler, or the MinGW compiler (based on GCC)


The GCC build as a number of requirements;

  • Automake X.XX
  • Autoconf X.XX
  • Autotools X.XX
  • SDL Development libraries 1.2.10 or greater (on Mac OS X you need 2.99 from svn and SDL 1.3 which is also only in SVN, to build BZFlag x86_64 binaries; i386 binaries should build fine using Mac OS X version 10.6 after setting the correct environment variables to avoid building x86_64 instead)
  • OpenGL Development libraries 1.1 or greater

If the required dependencies are installed, the user must then run the following commands from at root level of the source tree

 make install

Please note that depending on permissions levels the make install command may need to be run as an administrator or root. On Mac you can either run make to find any problems, or xcodebuild (after ./configure) to make an .app that is useable.


Launch XCode and open the bzflag/BZFlag.xcodeproj project. Note that XCode should have BZFlag selected as the active target and Development as the active build configuration. Click on Targets then click the Build icon. When this process completes, your application will be in bzflag/build/Development. You can then move it wherever you like.

Building on Snow Leopard

Snow Leopard defaults to 64-bit binaries, which isn't compatible with MacDisplay.cxx due to Carbon.framework not implementing a lot of functionality in 64-bit mode. To compile on Snow Leopard, you must build 32-bit.

Visual C++


In order to compile, you need to have Visual C++ 2003 or higher (Express version works just fine).
To get the latest Express version of Visual C++, visit


In order to compile you need ALL of the following:
Microsoft DirectX SDK April 2007 (Only the Headers and Libraries)
Windows Platform SDK (This is not required for Visual C++ 2008)

You then need to add them to your VC++ Directories, both include and lib folders.


In order to compile, you need to have Visual C++ 2008 or higher (Express version works just fine).
To get the latest Express version of Visual C++, visit


Microsoft DirectX SDK Febuary 2010

You then need to add them to your VC++ Directories, both include and lib folders.

Other build systems

Other build systems may be supported in the various readme files (minGW, IRIX, SOLARIS,etc..)

Solaris 10 (Oct, 2009)

This is what I had to do to get bzflag-2.0.12 to compile and run on Solaris 10

Install Sparc packages (in /opt) from Sunfreeware

You don't necessarily have to install in /opt. If not, skip all the "opt" stuff or substitute the correct location instead. Most of these packages will install in /usr/local. /usr/local was not available to me.


If you get an error saying that a library has moved, you might have to go into the library's .la file and update its location.

You will also have to update the *.la files if you get errors like this:

libtool: link: cannot find the library `/usr/local/lib/' or unhandled argument `/usr/local/lib/'

You will have to update these lines in SMCliconv/lib/, etc:

dependency_libs=' -R/usr/local/lib -R/usr/lib -R/usr/openwin/lib  -R/opt/SMCossl/ssl/lib  -R/usr/local/BerkeleyDB.4.7/lib -R/usr/local/BerkeleyDB.4.2/lib -R/usr/X11R6/lib 
-L/usr/local/lib -L/usr/lib -L/usr/openwin/lib  -L/opt/SMCossl/ssl/lib  -L/usr/local/BerkeleyDB.4.2/lib </b> /opt/SMClibidn/lib/ </b> -L/usr/local/pgsql/lib 
-L/usr/X11R6/lib /opt/SMClintl/lib/ -lsec -lc /opt/SMClssh2/lib/  /opt/SMCliconv/lib/  -lssl -lcrypto -lsocket -lnsl -lz'

Fix missing links

ln -s /usr/sfw/bin/gmake /usr/sfw/bin/make

ln -s /usr/xpg4/bin/ar /usr/bin/ar

Modify environment variables

export CPPFLAGS="-I/opt/SMClintl/include -I/opt/SMCossl/ssl/include -I/opt/SMCcurl/include -I/opt/SMClssh2/include"
export CPPFLAGS="$CPPFLAGS -I/opt/SMClibidn/include -L/opt/SMClintl/lib -L/opt/SMCossl/ssl/lib -L/opt/SMCcurl/lib "
export CPPFLAGS="$CPPFLAGS -L/opt/SMClssh2/lib -L/opt/SMClibidn/lib -L/opt/c-ares/lib -L/pt/SMCossl/ssl/lib -I/usr/openwin/include/GL"

export LDFLAGS="-L/usr/lib -L/opt/SMClintl/lib -L/opt/SMClibidn/lib -L/opt/SMClssh2/lib"

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/SMCcurl/lib:/opt/SMClibidn/lib:/opt/SMClintl/lib:/opt/SMClssh2/lib:/opt/SMCliconv/lib:/opt/SMCossl/lib:/opt/SMCossl/ssl/lib"

Run configure

./configure --with-libcurl=/opt/SMCcurl --prefix=/opt/bzflag --build=sun4

Edit sources

In include/SceneNode.h, change "glColor" to myColor":
(Solves the "Expected ')' before '->' token" error)

#define myColor3f(r, g, b)      SceneNode::myColor3f(r, g, b)
#define myColor4f(r, g, b, a)   SceneNode::myColor4f(r, g, b, a)
#define myColor3fv(rgb)         SceneNode::myColor3fv(rgb)
#define myColor4fv(rgba)        SceneNode::myColor4fv(rgba)

 static void         myColor3f(GLfloat r, GLfloat g, GLfloat b)
  #ifdef __MINGW32__
        {if (!colorOverride) ::myColor3f(r, g, b); };
        { (*color3f)(r, g, b); }

      static void         myColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
  #ifdef __MINGW32__
        {if (!colorOverride) ::myColor4f(r, g, b, a); };
        { (*color4f)(r, g, b, a); }

      static void         myColor3fv(const GLfloat* rgb)
  #ifdef __MINGW32__
        {if (!colorOverride) ::myColor3fv(rgb); };
        { (*color3fv)(rgb); }

      static void         myColor4fv(const GLfloat* rgba)
  #ifdef __MINGW32__
        {if (!colorOverride) ::myColor4fv(rgba); };

Fix Makefiles

Add -lresolv to LIBS in src/bzfs/Makefile, src/bzflag/Makefile, src/bzadmin/Makefile
(Solves the inet_aton unresolved symbol error)

LIBS = -lsocket -lm -lresolv

In src/platform edit the Makefile and uncomment the Solaris stuff:

am_libPlatform_la_OBJECTS = PlatformFactory.lo \
        BzfDisplay.lo \
        BzfJoystick.lo \
        BzfVisual.lo \
        BzfWindow.lo \
        BzfMedia.lo \
        wave.lo \
        SolarisPlatformFactory.lo \
        SolarisMedia.lo \
        XDisplay.lo \
        XVisual.lo \

(Makes sure platform.a gets built - this can probably be done with a configure switch, but I couldn't find it)

Make and test!

make; src/bzflag/bzflag