This wiki is archived and useful information is being migrated to the main bzflag.org website

Compiling

From BZFlagWiki
Revision as of 02:46, 13 May 2012 by JeffM2501 (Talk | contribs) (Add correct dependencies and mention that there may just happen to be other OSs then Linux.)

Jump to: navigation, search

Overview

Compiling BZFlag is the act of building executable applications for a target system using the raw source code. This is usually not necessary to install the game.

Obtaining sources

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.

Dependencies

In order to compile BZFlag, some third party libraries may be required depending on the operating system being built for. The readme file for each OS will contain the current dependencies for each OS and should be consulted before attempting any build.

The following is a general dependency list for version 2.4.

Windows

The only third party dependency required to build the client is the DirectX SDK that is available from Microsoft. A download is available at http://www.microsoft.com/en-us/download/details.aspx?id=6812.

If a user wishes to build a full set of windows installers, they will need to install the NSIS installer system, available from http://nsis.sourceforge.net.

All other dependencies are included.

Linux

Required Libraries

  • SDL development libraries (1.2.10 or greater)
  • SDL-sound development libraries (1.2.10 or greater)
  • libtool
  • automake
  • autoconf
  • g++
  • mesa development libraries (gl, and glu)
  • mesa development libraries

Required Libraries

These libraries are included with the source tree but users may have better results using ones included with a Linux distribution.

  • curl development libraries
  • c-ares development libraries
  • glew development libraries
  • zlib development libraries

Macintosh OSX

Required Libraries

  • SDL framework 1.2 (1.3 may not work on all versions of OSX)

Compilers

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)

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

 ./autogen.sh
 ./configure
 make
 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.

XCode

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++

2.0.x

Compiler
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 http://www.microsoft.com/express/vc/

Dependencies

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)
LibCURL
GLEW
PDCurses

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

2.99.x

Compiler
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 http://www.microsoft.com/express/vc/

Dependencies

Microsoft DirectX SDK Febuary 2010
PDCurses
LibCURL


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.

curl-7.19.6-sol10-sparc-local.gz
libidn-1.14-sol10-sparc-local.gz
libssh2-1.2-sol10-sparc-local.gz
openssl-0.9.8k-sol10-sparc-local.gz
libintl-3.4.0-sol10-sparc-local.gz
libiconv-1.11-sol10-sparc-local.gz

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/libidn.la' or unhandled argument `/usr/local/lib/libidn.la'

You will have to update these lines in SMCliconv/lib/libiconv.la, 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/libidn.la </b> -L/usr/local/pgsql/lib 
-L/usr/X11R6/lib /opt/SMClintl/lib/libintl.la -lsec -lc /opt/SMClssh2/lib/libssh2.la  /opt/SMCliconv/lib/libiconv.la  -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); };
  #else
        { (*color3f)(r, g, b); }
  #endif

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

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

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

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 \
        XWindow.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