I've been tied up with recruiting related work, primarily reading resumes, looking at demo reels and doing phone screens. I got a bit tired of it all a couple of days back and decided to spend a bit of time doing what I like - think of it as brief break from the Axham Games studio setup work.
Building the boost binaries is one of the optional steps for building the Ogre graphics engine from source. I ran into a few difficulties building the boost binaries on MinGW.
Assumptions: You're familiar with Windows & Unix utilities, shell scripting ( bash & cmd ), know about command line compilation and are generally fearless, like a lion.
Here's my development setup:
| Platform | Windows 7 x64 |
| Toolchain | mingw gcc on msys which you can get here. |
| gcc version | 4.7.0 - get this with mingw |
| Boost version | 1.51 from boost.org |
Note: I build all default libraries in boost, rather than just the bare minimum required for Ogre. Takes a couple of hours on my circa 2009 Intel Core i7 laptop with 4GB RAM & Seagate Momentus XT SATA II HDDs.
Note 2: I've learned the hard way that using a tilde i.e. ~ in args that take a path to b2 under mingw, result in a directory with the name ~ being created in the current directory into which relevant files are placed. So, don't pass a ~ to b2.
Note 3: This one's slightly "duh", but readlink will fail silently if you pass it a non-existent link, file or path. So, I pre-create directories where needed.
- Get boost 1.51 from boost.org.
- Put it in ~/external/boost, so your boost source root will be ~/external/boost/boost_1_51_0
- We're going to use this a few times in the future, so set it as an environment var.
export BOOST_SRC_ROOT=~/external/boost/boost_1_51_0
cd $BOOST_SRC_ROOT
cd tools/build/v2
- To build the binary parts of boost, we first need to build the boost build system.
./bootstrap.sh --with-toolset=mingw
Note that the documentation on the boost wiki is wrong. You must pass the toolset you want to use using the above syntax for boost build to build in mingw. Simply passing gcc or mingw will cause the build to fail with something like this in the error log:
$ sh bootstrap.sh
Bootstrapping the build engine with toolset gcc...
Failed to bootstrap the build engine
Consult 'bootstrap.log' for more details
$ cat bootstrap.log
###
### Using 'gcc' toolset.
###
rm -rf bootstrap
mkdir bootstrap
gcc -o bootstrap/jam0 command.c compile.c constants.c debug.c function.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c object.c option.c output.c parse.c pathunix.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c pwd.c class.c native.c md5.c w32_getreg.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c execunix.c fileunix.c
builtins.c:33:23: fatal error: sys/wait.h: No such file or directory
compilation terminated.
execunix.c:17:26: fatal error: sys/resource.h: No such file or directory
compilation terminated.
fileunix.c:98:17: fatal error: ar.h: No such file or directory
compilation terminated.
- Set output and installation directories and build.
export BUILD_OUTPUT_DIR=~/build/output
export BUILD_INSTALL_DIR=~/build/install
export BOOST_VERSION=1_51_0
export BOOST_BUILD_DIR=$BUILD_OUTPUT_DIR/boost_$BOOST_VERSION
export BOOST_INSTALL_DIR=$BUILD_INSTALL_DIR/boost_$BOOST_VERSION
mkdir -p $BOOST_BUILD_DIR
mkdir -p $BOOST_INSTALL_DIR
./b2 toolset=gcc --prefix=$BOOST_BUILD_DIR/build install
export PATH=$PATH:$BOOST_BUILD_DIR/build/bin
- mingw specific: Comment out the following line ( around line 486 ) in tools/python.jam:
python-cmd = "$(python-cmd)" ; It's within this if block:
if [ version.check-jam-version 3 1 17 ] || ( [ os.name ] != NT )
- Now that the boost build system is built and installed, time to build the actual boost library binaries.
cd $BOOST_SRC_ROOT
b2 --build-dir=$BOOST_BUILD_DIR toolset=gcc --prefix=$BOOST_INSTALL_DIR install 2>&1 | tee $BOOST_BUILD_DIR/build.log
That will build static and shared non-debug multi-threaded variants of the libraries. To build all variants, pass the additional option, --build-type=complete
- Check the build log for errors, you should have 12 failures due to missing unicode/uversion.h which you can safely ignore ( some internal check for optional stuff that should be warnings ). At the end of the build process, you should have the boost libs installed in ~/build/output/boost_1_51_0/lib and headers in the boost subdir under ~/build/output/boost_1_51_0/include/boost-1_51.
Note: Header files in mingw are in nested one level deeper than in posix builds i.e. in posix the dir structure looks like $BOOST_ROOT/include/boost and in mingw it's $BOOST_ROOT/include/boost-1_51/boost. So, when using boost in multi-platform builds like I do, you need to adjust your include path accordingly.
Posix Build Specifics ( Ubuntu LTS 12.04 )
To get boost to build without errors under Ubuntu LTS 12.04, you need to install the following additional libraries via apt-get:
- python-dev
- libbz2-dev
Update: Added posix build info.
Update 2012-10-30: Fixed paths and added note to comment out line 489 in tools/python.jam
