Skip to content
dknoester edited this page Dec 4, 2012 · 9 revisions

There are three things you need to do to get started developing with EALib: Install Boost, install EALib, and check that it works. Installing Boost, unfortunately, is the most complicated part - Stick with it, be patient, and remember to take deep breaths. Here we go...

Prerequisites

  • You need a working development environment. On OS X, this is Xcode, which can be downloaded from the App Store. On Ubuntu, this can be done by executing this command in a terminal:

      % sudo apt-get install build-essential
    
  • Install zlib. This should be installed by default, but you might have to go get it from MacPorts (OS X) or other platform-specific package repository. If you're not sure if it's installed, check /usr/lib, /opt/local/lib, and /usr/ local/lib for libz.* (your system is not likely to have all these directories present; that's ok).

  • Install the Boost C++ libraries and Boost.Build. Detailed instructions specific to EALib can be found here. However, Boost changes fairly frequently. If you run into problems, use the "Getting started" guide that can be found at http://www.boost.org. By the way, many of the popular package management systems (MacPorts, Fink, Ubuntu, etc.) package Boost and Boost.Build incorrectly. I strongly recommend installing it from source.

  • If you need to build EALib projects outside of XCode, the only officially supported build tool is Boost.Build. See here for instructions on getting Boost.Build setup correctly.

Installing Boost

Why do you need to install Boost like this? Because very few package management systems package the Boost libraries AND Boost.Build correctly. If you don't care about Boost.Build, and/or are feeling adventurous, feel free to explore MacPorts (OS X) or the package repositories appropriate for your platform. Directions in this document are for OS X and Ubuntu.

Step 0: Conventions and prefix

  • Text like this refers to something that is case & punctuation specific, for example, a path like /usr/local.

  • % Text like this, prefixed with a %, should be executed in a terminal. For example, % ./b2 means to type ./b2 in a terminal (command prompt, like bash), and press enter to execute the b2 command.

  • Decide where you are going to install the Boost libraries. This is called the prefix. The default prefix on Unix-like systems is /usr/local. If you don't have root permissions on your system, you will need to use your home directory as the prefix. In the rest of this document, wherever you see prefix, either: omit it if you are using the default, or replace it with your home directory. For example, % ./bootstrap.sh --prefix=prefix means execute ./bootstrap.sh in a terminal if you are using the default location, or execute ./bootstrap.sh --prefix=${HOME} in a terminal if you are using your home directory. Note that ${HOME} is shorthand for your home directory on Unix-like systems.

  • If you are installing to /usr/local, you'll need to have root permissions. In the directions that follow, wherever you see sudo, include it only if you have root privileges and you are installing to somewhere that requires them (e.g., /usr/local). For example, if you are installing to your home directory and you see % sudo ./b2 install, you should execute ./b2 install instead of sudo ./b2 install. If you have root privileges and are installing to /usr/local, you would execute sudo ./b2 install.

Step 1: Building the Boost libraries

Download the "Current Release" version of the Boost libraries from http://www.boost.org. At the time of this writing, this was 1.48, which could be downloaded here. Un-(zip,tar,7z) the file to a temporary location, and change directory (cd) to the resulting top-level boost directory (e.g., boost-1.48).

OS X:

% ./bootstrap.sh --prefix=prefix --with-python-root=/System/Library/Frameworks/Python.framework/Versions/Current --with-toolset=darwin
% ./b2 --without-mpi

Ubuntu:

% ./bootstrap.sh --prefix=prefix --with-toolset=gcc
% ./b2 --without-mpi

This step should take a while. When it's done, you should see something like this:

The Boost C++ Libraries were successfully built!
...
The following directory should be added to compiler include paths:
...      
The following directory should be added to linker library paths:
...

If you see something different, something went wrong. Try googling the error message. DON'T CONTINUE WITH THESE DIRECTIONS UNTIL THIS STEP WORKS.

Step 2: Installing the Boost libraries

From inside the boost directory:

% sudo ./b2 --without-mpi install

You should see a large list scroll by, and then something like … updated X targets… where X is probably a largish number. To make sure there were no errors, make sure that % echo $? responds with 0.

Step 3: Installing and configuring Boost.Build

Again, from inside the boost directory:

% cd tools/build/v2
% ./bootstrap.sh
% sudo ./b2 install --prefix=prefix

That installed the Boost.Build system. Now we need to make the Boost libraries available to your own jamfiles (these are the Boost.Build equivalent of a Makefile):

% sudo cp contrib/boost.jam prefix/share/boost-build/build

Now we need to create a site-config.jam file, which makes Boost.Build much easier to use. If you installed Boost to the default prefix (usually /usr/local), then put this:

using toolset ;
import boost ;
boost.use-project ;
project site-config ;
lib z ;

... in a file named prefix/share/boost-build/site-config.jam Replace toolset above with darwin if you're using OS X, or gcc if you're using Ubuntu. If you installed Boost elsewhere, things are a little more complicated -- Put this:

using toolset ;
local INC = prefix/include ;
local LIB = prefix/lib ;
import boost ;
using boost : version : 
    <include>$(INC)
    <library>$(LIB)
    <layout>system
    ;
boost.use-project version ;
project site-config ;
lib z ;

... in a file named prefix/share/boost-build/site-config.jam Replace toolset above with the toolset you built Boost with (darwin on OS X, gcc on Ubuntu). Also replace prefix with the path to your prefix, and replace version with the version of Boost you installed (e.g., 1.48).

Step 4: Finishing up

Add prefix/bin to your PATH environment variable, and create an environment variable named BOOST_BUILD_PATH that points to prefix/share/boost-build. If you're using bash (the OS X default), put this:

export PATH=prefix/bin:$PATH
export BOOST_BUILD_PATH=prefix/share/boost-build

in the .bashrc file in your home directory (create this file if it doesn't exist). Replace prefix above with your prefix.

Using Boost

Link against the Boost libraries in prefix/lib, compile against the headers in prefix/include. If you're using Boost.Build (bjam), the following is an example jamfile that links against the Boost program options library:

exe hello : hello.cpp : <library>/boost//program_options ;

Installing EALib

In progress.

Testing EALib

In progress.