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

Difference between revisions of "Compiling"

From BZFlagWiki
Jump to: navigation, search
(updated Mac section somewhat)
m (Obtaining sources: fixed links)
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
==Overview==
 
==Overview==
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.
+
Compiling BZFlag is the act of building executable applications for a target system using the raw source code..
  
==Source Code==
+
==Obtaining sources==
In order to compile a user must have his or her own copy of the [[BZFlag_Source|Source Code]]. The code can be obtained from a source archive from the [[Download]] page, or from the BZFlag [[BZFlag_SVN|Subversion]] server.
+
In order to compile a user must have his or her own copy of the [[BZFlag Source|Source Code]]. The code can be obtained from a source archive from the [http://bzflag.org/downloads download] page, or from [[BZFlag Git|Git]].
  
==Readme Files==
+
==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.
 
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.
  
Line 11: Line 11:
 
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.
 
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.
+
* Windows computers can use the Visual C++ compiler, or the MinGW compiler (based on GCC). Windows is the most popular client OS and nearly all clients are built with the Visual C++ compiler, including the official binaries.
* Macintosh computers use the XCode compiler (or gcc, see notes).
+
* Macintosh OS X computers use the Xcode compiler (or optionally gcc, see notes). OS X is the second most popular client OS, official builds are built with Xcode, not GCC.
* Windows computers can use the Visual C++ compiler, or the MinGW compiler (based on GCC)
+
* Linux and BSD computers use the GCC compiler. Linux is the third most common client OS and packages for distributions are built using GCC.
 +
 
 +
===Visual C++===
 +
The most common way to build on windows to to use the Visual C++ 2010 compiler (Both Express and Retail versions are supported).
 +
The current free Express version of Visual C++ can be found at [http://www.microsoft.com/express/vc/ http://www.microsoft.com/express/vc/]
  
 
===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
 
If the required dependencies are installed, the user must then run the following commands from at root level of the source tree
  
Line 30: Line 27:
 
   make install
 
   make install
  
Please note that depending on permissions levels the '''make install''' command may need to be run as an administrator or root.
+
Please note that depending on permissions levels the '''make install''' command may need to be run as an administrator or root. On Macintosh OS X, do not run make install when building with GCC. Run the program from the source directory or install it manually as desired instead.
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'''<br>
+
In order to compile, you need to have Visual C++ 2003 or higher (Express version works just fine).<br>
+
To get the latest Express version of Visual C++, visit [http://www.microsoft.com/express/vc/ http://www.microsoft.com/express/vc/]<br>
+
 
+
'''Dependencies'''
+
 
+
In order to compile you need '''ALL''' of the following:<br>
+
[http://www.microsoft.com/downloads/details.aspx?FamilyID=86cf7fa2-e953-475c-abde-f016e4f7b61a&DisplayLang=en Microsoft DirectX SDK April 2007] (Only the Headers and Libraries)<br>
+
[http://www.microsoft.com/downloads/details.aspx?familyid=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en Windows Platform SDK] (This is not required for Visual C++ 2008) <br>
+
[http://curl.haxx.se/download/libcurl-7.18.0-win32-msvc.zip LibCURL]<br>
+
[http://sourceforge.net/project/downloading.php?group_id=67586&use_mirror=superb-east&filename=glew-1.5.1-win32.zip&1970168 GLEW] <br>
+
[http://sourceforge.net/project/downloading.php?group_id=30480&use_mirror=superb-west&filename=pdc34dll.zip&38017788 PDCurses] <br>
+
 
+
You then need to add them to your VC++ Directories, both include and lib folders.
+
 
+
==== 2.99.x =====
+
 
+
'''Compiler'''<br>
+
In order to compile, you need to have Visual C++ 2008 or higher (Express version works just fine).<br>
+
To get the latest Express version of Visual C++, visit [http://www.microsoft.com/express/vc/ http://www.microsoft.com/express/vc/]<br>
+
 
+
'''Dependencies'''<br>
+
 
+
[http://www.microsoft.com/downloads/details.aspx?FamilyId=5493F76A-6D37-478D-BA17-28B1CCA4865A&displaylang=en Microsoft DirectX SDK November 2008]<br>
+
[http://sourceforge.net/project/downloading.php?group_id=30480&use_mirror=superb-west&filename=pdc34dll.zip&38017788 PDCurses] <br>
+
 
+
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 [http://sunfreeware.com 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. 
+
 
+
<pre>
+
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
+
</pre>
+
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 <b> -R/opt/SMCossl/ssl/lib </b> -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 <b> -L/opt/SMCossl/ssl/lib </b> -L/usr/local/BerkeleyDB.4.2/lib </b> /opt/SMClibidn/lib/libidn.la </b> -L/usr/local/pgsql/lib
+
-L/usr/X11R6/lib <b>/opt/SMClintl/lib/libintl.la</b> -lsec -lc <b>/opt/SMClssh2/lib/libssh2.la  /opt/SMCliconv/lib/libiconv.la </b> -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
+
<pre>
+
 
+
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"
+
===Xcode===
</pre>
+
The Xcode system uses the  '''Xcode/BZFlag.xcodeproj''' project. Building is fairly straightforward. Follow the instructions in the README.MacOSX file.
Run configure
+
<pre>
+
./configure --with-libcurl=/opt/SMCcurl --prefix=/opt/bzflag --build=sun4
+
</pre>
+
Edit sources
+
<pre>
+
In include/SceneNode.h, change "glColor" to myColor":
+
(Solves the "Expected ')' before '->' token" error)
+
  
#define myColor3f(r, g, b)      SceneNode::myColor3f(r, g, b)
+
==Dependencies==
#define myColor4f(r, g, b, a)  SceneNode::myColor4f(r, g, b, a)
+
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.
#define myColor3fv(rgb)        SceneNode::myColor3fv(rgb)
+
#define myColor4fv(rgba)        SceneNode::myColor4fv(rgba)
+
  
static void        myColor3f(GLfloat r, GLfloat g, GLfloat b)
+
The following is a general dependency list for version 2.4.
  #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)
+
===Windows (Visual Studio)===
  #ifdef __MINGW32__
+
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 (!colorOverride) ::myColor4f(r, g, b, a); };
+
  #else
+
        { (*color4f)(r, g, b, a); }
+
  #endif
+
  
      static void        myColor3fv(const GLfloat* rgb)
+
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.
  #ifdef __MINGW32__
+
        {if (!colorOverride) ::myColor3fv(rgb); };
+
  #else
+
        { (*color3fv)(rgb); }
+
  #endif
+
  
      static void        myColor4fv(const GLfloat* rgba)
+
All other dependencies are included.
  #ifdef __MINGW32__
+
        {if (!colorOverride) ::myColor4fv(rgba); };
+
  #else
+
</pre>
+
Fix Makefiles
+
<pre>
+
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
+
===Linux (GCC)===
 +
====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
  
In src/platform edit the Makefile and uncomment the Solaris stuff:
+
====Optional Libraries====
 +
These libraries are included with the source tree but users may have better results using ones included with a Linux distribution.
  
am_libPlatform_la_OBJECTS = PlatformFactory.lo \
+
* curl development libraries
        BzfDisplay.lo \
+
* c-ares development libraries
        BzfJoystick.lo \
+
* glew development libraries
        BzfVisual.lo \
+
* zlib development libraries
        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)
+
===Macintosh OS X (Xcode or GCC)===
</pre>
+
====Required Libraries====
Make and test!
+
* SDL framework 1.2 (1.3 may not work on all versions of OSX)
  
make; src/bzflag/bzflag
+
==Other build systems==
 +
Other build systems may be supported in the various readme files (minGW, IRIX, SOLARIS,etc..) see the [[Compiling/Solaris_Notes]] page for more info.
  
 
[[Category:Development]]
 
[[Category:Development]]
 
[[Category:Compiling]]
 
[[Category:Compiling]]
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]

Latest revision as of 01:44, 22 November 2016

Overview[edit]

Compiling BZFlag is the act of building executable applications for a target system using the raw source code..

Obtaining sources[edit]

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 Git.

README files[edit]

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.

Compilers[edit]

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.

  • Windows computers can use the Visual C++ compiler, or the MinGW compiler (based on GCC). Windows is the most popular client OS and nearly all clients are built with the Visual C++ compiler, including the official binaries.
  • Macintosh OS X computers use the Xcode compiler (or optionally gcc, see notes). OS X is the second most popular client OS, official builds are built with Xcode, not GCC.
  • Linux and BSD computers use the GCC compiler. Linux is the third most common client OS and packages for distributions are built using GCC.

Visual C++[edit]

The most common way to build on windows to to use the Visual C++ 2010 compiler (Both Express and Retail versions are supported). The current free Express version of Visual C++ can be found at http://www.microsoft.com/express/vc/

GCC[edit]

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 Macintosh OS X, do not run make install when building with GCC. Run the program from the source directory or install it manually as desired instead.

Xcode[edit]

The Xcode system uses the Xcode/BZFlag.xcodeproj project. Building is fairly straightforward. Follow the instructions in the README.MacOSX file.

Dependencies[edit]

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 (Visual Studio)[edit]

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 (GCC)[edit]

Required Libraries[edit]

  • 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

Optional Libraries[edit]

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 OS X (Xcode or GCC)[edit]

Required Libraries[edit]

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

Other build systems[edit]

Other build systems may be supported in the various readme files (minGW, IRIX, SOLARIS,etc..) see the Compiling/Solaris_Notes page for more info.