Difference between revisions of "Compiling"

From VDrift
Jump to: navigation, search
m (1 revision: Import from old wiki (on 15 May 2012))
 
(Combine all compiling pages, using collapsing sections)
Line 1: Line 1:
#REDIRECT [[Compiling VDrift]]
+
This page shows how to compile VDrift from source. It assumes you have downloaded the source code either by getting the source package from the [[Downloading|latest release]], or by [[Getting the development version|getting the development version]].
 +
__TOC__
 +
 
 +
<div class="mw-collapsible mw-collapsed">
 +
==Windows==
 +
<div class="mw-collapsible-content">
 +
===Building with Code::Blocks/MinGW===
 +
* Download the [http://sourceforge.net/projects/mingw/files/ latest MinGW]. When asked to select components for install, you only need the base system and the g++ compiler.
 +
* Your PATH Environment Variable should contain the MinGW bin path (e.g. C:\MinGW\bin;).
 +
* Download [http://forums.codeblocks.org/index.php/board,20.0.html Code::Blocks nightly]
 +
* Run the following command from the '''vdrift''' folder to generate the build files.
 +
vdrift-win\premake4 codeblocks
 +
 
 +
===Building with MSVC===
 +
* Run the appropriate command from the '''vdrift''' folder to generate the build files.
 +
** Microsoft Visual C++ 2008:
 +
vdrift-win\premake4 vs2008
 +
** Microsoft Visual C++ 2010:
 +
vdrift-win\premake4 vs2010
 +
 
 +
===Building with Scons(broken)===
 +
{{note|SCons will prefer the MSVC tools over the MinGW. So if you have Microsoft Visual Studio installed, you might have problems building VDrift with Scons.}}
 +
* Download the [http://sourceforge.net/projects/mingw/files/ latest MinGW]. When asked to select components for install, you only need the base system and the g++ compiler.
 +
* Your PATH environment variable should contain the MinGW bin path (e.g. C:\MinGW\bin;).
 +
* Download [http://www.python.org/ftp/python/2.6.4/python-2.6.4.msi Python 2.6.4].
 +
* Run the installer and accept all the defaults.
 +
* Download [http://www.scons.org/ SCons 1.20].
 +
* Run the installer. It should find your Python installation, accept all defaults.
 +
* Your PATH environment variable should contain the Python and Python scripts paths (e.g. C:\Python26;C:\Python26\Scripts;).
 +
* Run the following command from within the '''vdrift''' folder:
 +
tools/win/bin/build_vdrift.bat
 +
</div></div>
 +
 
 +
<div class="mw-collapsible mw-collapsed">
 +
==OS X==
 +
<div class="mw-collapsible-content">
 +
The VDrift OS X project requires [http://developer.apple.com/xcode/ Xcode] 3.2 or later. The latest version is free on the [http://itunes.apple.com/us/app/xcode/id422352214?mt=12&ls=1 Mac App Store].
 +
 
 +
Open '''vdrift/vdrift-mac/vdrift.xcodeproj''' and in Xcode 4 or higher click Product -> Build, otherwise hit Build -> Build.
 +
</div></div>
 +
 
 +
<div class="mw-collapsible mw-collapsed">
 +
==Linux==
 +
<div class="mw-collapsible-content">
 +
===Prerequisites===
 +
The required build tools include:
 +
 
 +
* [http://gcc.gnu.org/ g++] - The GNU C++ compiler
 +
* [http://scons.org/scons SCons] - A replacement for Make
 +
 
 +
The required libraries include:
 +
 
 +
* [http://libarchive.github.com/ libarchive] - library for reading and writing archive formats
 +
* [http://bulletphysics.org/wordpress/ libbullet] - Bullet Physics Library: the '''BulletCollision''', '''BulletDynamics''', '''LinearMath''' libraries are required
 +
* [http://curl.haxx.se/ libcurl] - the multiprotocol file transfer library
 +
* [http://glew.sourceforge.net/ libglew] - OpenGL extension utilities
 +
* [http://www.libsdl.org/ libsdl] - Simple Direct Media Layer
 +
* [http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx libsdl-gfx] - Graphics drawing primitives library for SDL
 +
* [http://www.libsdl.org/projects/SDL_image/ libsdl-image] - Image file loading library for SDL
 +
* [http://xiph.org/vorbis/ libvorbis] - The Vorbis General Audio Compression Codec
 +
* vorbisfile - File loading library for the ogg vorbis format
 +
* [http://www.boost.org/ Boost C++ Libraries] (header-file-only)
 +
 
 +
Make sure you have all the required libraries and build tools. Make sure you also have the development files for each of the libraries. Your Linux distribution may have different package names and/or bundled differently. The list above should give enough information to search for applicable packages within your distribution's package manager.
 +
 
 +
====Fedora====
 +
All required packages can be installed using this command:
 +
sudo yum install bullet-devel gcc-c++ glew-devel libarchive-devel scons SDL_*-devel curl-devel
 +
 
 +
====Ubuntu====
 +
Ubuntu does not include a libbullet package, but getdeb does. To add the getdeb-repository to your sources-list.d:
 +
wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
 +
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu natty-getdeb games" > /etc/apt/sources.list.d/getdeb.list'
 +
sudo apt-get update
 +
 
 +
Ubuntu 11.04 (Natty Narwhal) does contain libglew1.5, only. To install libglew1.6 and its development headers:
 +
wget http://archive.ubuntu.com/ubuntu/pool/universe/g/glew/libglew1.6_1.6.0-3_amd64.deb
 +
sudo dpkg -i libglew1.6_1.6.0-3_amd64.deb
 +
rm libglew1.6_1.6.0-3_amd64.deb
 +
 
 +
wget http://archive.ubuntu.com/ubuntu/pool/universe/g/glew/libglew1.6-dev_1.6.0-3_amd64.deb
 +
sudo dpkg -i libglew1.6-dev_1.6.0-3_amd64.deb
 +
rm libglew1.6-dev_1.6.0-3_amd64.deb
 +
 
 +
All other required packages can be installed using this command:
 +
sudo apt-get install g++ libarchive-dev libcurl4-gnutls-dev \
 +
                      libdrm-dev libgl1-mesa-dev \
 +
                      libglu1-mesa-dev libkms1 mesa-common-dev \
 +
                      libsdl-gfx1.2-dev libsdl-image1.2-dev \
 +
                      libsdl-net1.2-dev libvorbis-dev freeglut3 libbullet0 \
 +
                      libbullet-dev scons
 +
 
 +
===Compiling===
 +
To compile VDrift just run SCons in the root directory of the sources.
 +
scons
 +
 
 +
====Optional: Compile Options====
 +
You can use one or more compile options. To compile with optimization for a certain platform, you can use the arch flag:
 +
scons arch=a64
 +
Compiling VDrift in release mode will turn off debugging options, and enable more compiler optimizations.  VDrift runs much more quickly in release mode:
 +
scons release=1
 +
To enable force feedback, use this flag:
 +
scons force_feedback=1
 +
You can get a list of all compile time options with:
 +
scons --help
 +
These options are probably best left off the first time you compile. If you have problems compiling or running VDrift, it is easier to debug with them off. Once you verify that VDrift is compiling, then recompile with these optimizations to improve performance.
 +
 
 +
===Installing===
 +
VDrift does not need to be installed to work and you can run it from the folder where you compiled it. If you do want to install, use the SCons build target install.
 +
sudo scons install
 +
 
 +
====Optional: Installation Location====
 +
There are also some install options - to change where VDrift is installed, use the prefix flag:
 +
scons install prefix=/usr/local
 +
 
 +
===Cleaning===
 +
Building the project creates several artefacts that do not need to be stored, because they can be regenerated on demand. Cleaning them up can be done with SCons, too:
 +
scons --clean
 +
To remove all additional temporary files run:
 +
rm -rf .sconf_temp/ .sconsign.dblite config.log vdrift.conf
 +
</div></div>
 +
 
 +
<div class="mw-collapsible mw-collapsed">
 +
==FreeBSD==
 +
<div class="mw-collapsible-content">
 +
To compile VDrift on FreeBSD, use the ports system.
 +
 
 +
===Latest Release===
 +
If you downloaded a release, simply run <code>make</code> on the '''vdrift''' port:
 +
  cd /usr/ports/games/vdrift && make install clean clean-depends
 +
 
 +
===Development Version===
 +
If you downloaded the development version, copy the '''vdrift''' and '''vdrift-data''' ports to '''vdrift-devel''' and '''vdrift-data-devel''':
 +
  cd /usr/ports/games && cp -rf vdrift vdrift-devel && cp -rf vdrift-data vdrift-data-devel
 +
To compile, run <code>make</code> on the newly-created '''vdrift-devel''' port:
 +
  cd /usr/ports/games/vdrift-devel && make install clean clean-depends
 +
</div></div>
 +
 
 +
[[Category:Development]]

Revision as of 13:51, 26 August 2012

This page shows how to compile VDrift from source. It assumes you have downloaded the source code either by getting the source package from the latest release, or by getting the development version.

Windows

Building with Code::Blocks/MinGW

  • Download the latest MinGW. When asked to select components for install, you only need the base system and the g++ compiler.
  • Your PATH Environment Variable should contain the MinGW bin path (e.g. C:\MinGW\bin;).
  • Download Code::Blocks nightly
  • Run the following command from the vdrift folder to generate the build files.
vdrift-win\premake4 codeblocks

Building with MSVC

  • Run the appropriate command from the vdrift folder to generate the build files.
    • Microsoft Visual C++ 2008:
vdrift-win\premake4 vs2008
    • Microsoft Visual C++ 2010:
vdrift-win\premake4 vs2010

Building with Scons(broken)

Note: SCons will prefer the MSVC tools over the MinGW. So if you have Microsoft Visual Studio installed, you might have problems building VDrift with Scons.
  • Download the latest MinGW. When asked to select components for install, you only need the base system and the g++ compiler.
  • Your PATH environment variable should contain the MinGW bin path (e.g. C:\MinGW\bin;).
  • Download Python 2.6.4.
  • Run the installer and accept all the defaults.
  • Download SCons 1.20.
  • Run the installer. It should find your Python installation, accept all defaults.
  • Your PATH environment variable should contain the Python and Python scripts paths (e.g. C:\Python26;C:\Python26\Scripts;).
  • Run the following command from within the vdrift folder:
tools/win/bin/build_vdrift.bat

OS X

The VDrift OS X project requires Xcode 3.2 or later. The latest version is free on the Mac App Store.

Open vdrift/vdrift-mac/vdrift.xcodeproj and in Xcode 4 or higher click Product -> Build, otherwise hit Build -> Build.

Linux

Prerequisites

The required build tools include:

  • g++ - The GNU C++ compiler
  • SCons - A replacement for Make

The required libraries include:

  • libarchive - library for reading and writing archive formats
  • libbullet - Bullet Physics Library: the BulletCollision, BulletDynamics, LinearMath libraries are required
  • libcurl - the multiprotocol file transfer library
  • libglew - OpenGL extension utilities
  • libsdl - Simple Direct Media Layer
  • libsdl-gfx - Graphics drawing primitives library for SDL
  • libsdl-image - Image file loading library for SDL
  • libvorbis - The Vorbis General Audio Compression Codec
  • vorbisfile - File loading library for the ogg vorbis format
  • Boost C++ Libraries (header-file-only)

Make sure you have all the required libraries and build tools. Make sure you also have the development files for each of the libraries. Your Linux distribution may have different package names and/or bundled differently. The list above should give enough information to search for applicable packages within your distribution's package manager.

Fedora

All required packages can be installed using this command:

sudo yum install bullet-devel gcc-c++ glew-devel libarchive-devel scons SDL_*-devel curl-devel

Ubuntu

Ubuntu does not include a libbullet package, but getdeb does. To add the getdeb-repository to your sources-list.d:

wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu natty-getdeb games" > /etc/apt/sources.list.d/getdeb.list'
sudo apt-get update

Ubuntu 11.04 (Natty Narwhal) does contain libglew1.5, only. To install libglew1.6 and its development headers:

wget http://archive.ubuntu.com/ubuntu/pool/universe/g/glew/libglew1.6_1.6.0-3_amd64.deb
sudo dpkg -i libglew1.6_1.6.0-3_amd64.deb
rm libglew1.6_1.6.0-3_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/g/glew/libglew1.6-dev_1.6.0-3_amd64.deb
sudo dpkg -i libglew1.6-dev_1.6.0-3_amd64.deb
rm libglew1.6-dev_1.6.0-3_amd64.deb

All other required packages can be installed using this command:

sudo apt-get install g++ libarchive-dev libcurl4-gnutls-dev \
                     libdrm-dev libgl1-mesa-dev \
                     libglu1-mesa-dev libkms1 mesa-common-dev \
                     libsdl-gfx1.2-dev libsdl-image1.2-dev \
                     libsdl-net1.2-dev libvorbis-dev freeglut3 libbullet0 \
                     libbullet-dev scons

Compiling

To compile VDrift just run SCons in the root directory of the sources.

scons

Optional: Compile Options

You can use one or more compile options. To compile with optimization for a certain platform, you can use the arch flag:

scons arch=a64

Compiling VDrift in release mode will turn off debugging options, and enable more compiler optimizations. VDrift runs much more quickly in release mode:

scons release=1

To enable force feedback, use this flag:

scons force_feedback=1

You can get a list of all compile time options with:

scons --help

These options are probably best left off the first time you compile. If you have problems compiling or running VDrift, it is easier to debug with them off. Once you verify that VDrift is compiling, then recompile with these optimizations to improve performance.

Installing

VDrift does not need to be installed to work and you can run it from the folder where you compiled it. If you do want to install, use the SCons build target install.

sudo scons install

Optional: Installation Location

There are also some install options - to change where VDrift is installed, use the prefix flag:

scons install prefix=/usr/local

Cleaning

Building the project creates several artefacts that do not need to be stored, because they can be regenerated on demand. Cleaning them up can be done with SCons, too:

scons --clean

To remove all additional temporary files run:

rm -rf .sconf_temp/ .sconsign.dblite config.log vdrift.conf

FreeBSD

To compile VDrift on FreeBSD, use the ports system.

Latest Release

If you downloaded a release, simply run make on the vdrift port:

 cd /usr/ports/games/vdrift && make install clean clean-depends

Development Version

If you downloaded the development version, copy the vdrift and vdrift-data ports to vdrift-devel and vdrift-data-devel:

 cd /usr/ports/games && cp -rf vdrift vdrift-devel && cp -rf vdrift-data vdrift-data-devel

To compile, run make on the newly-created vdrift-devel port:

 cd /usr/ports/games/vdrift-devel && make install clean clean-depends