Changes between Initial Version and Version 1 of Programming/Cpp/Boost/BuildingBoostOnMinGw


Ignore:
Timestamp:
Feb 18, 2016, 6:18:31 PM (8 years ago)
Author:
Vijay Varadan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Programming/Cpp/Boost/BuildingBoostOnMinGw

    v1 v1  
     1= Build boost on MinGW =
     2Oct 19 2012
     3
     4[[Image(htdocs:images/boost/boost-logo.png, alt="boost c++ library", align=center)]]
     5
     6Building the boost binaries is one of the optional steps for building the [http://ogre3d.org Ogre] graphics engine from source. I ran into a few difficulties building the [http://boost.org boost] binaries on MinGW.
     7
     8'''Assumptions:''' You're familiar with Windows & Unix utilities, shell scripting ( bash & cmd ), know about command line compilation and are generally fearless, like a lion.
     9
     10Here's my development setup:
     11||Platform||Windows 7 x64||
     12||Toolchain||mingw gcc on msys which you can get [http://www.mingw.org/ here].||
     13||gcc version||4.7.0 - get this with mingw||
     14||Boost version||1.51 from [http://boost.org boost.org]||
     15
     16'''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.
     17
     18'''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.
     19
     20'''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.
     21
     221. Get boost 1.51 from [boost.org boost.org].
     231. Put it in `~/external/boost`, so your boost source root will be `~/external/boost/boost_1_51_0`
     241. We're going to use this a few times in the future, so set it as an environment var.
     25{{{#!bash
     26export BOOST_SRC_ROOT=~/external/boost/boost_1_51_0
     27cd $BOOST_SRC_ROOT
     28cd tools/build/v2
     29}}}
     301. To build the binary parts of boost, we first need to build the boost build system.
     31{{{#!bash
     32./bootstrap.sh --with-toolset=mingw
     33}}}
     34Note that the documentation on the boost wiki is wrong. You <strong>_must_</strong>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:
     35{{{#!bash
     36$ sh bootstrap.sh
     37Bootstrapping the build engine with toolset gcc...
     38Failed to bootstrap the build engine
     39Consult 'bootstrap.log' for more details
     40$ cat bootstrap.log
     41###
     42### Using 'gcc' toolset.
     43###
     44rm -rf bootstrap
     45mkdir bootstrap
     46gcc -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
     47builtins.c:33:23: fatal error: sys/wait.h: No such file or directory
     48compilation terminated.
     49execunix.c:17:26: fatal error: sys/resource.h: No such file or directory
     50compilation terminated.
     51fileunix.c:98:17: fatal error: ar.h: No such file or directory
     52compilation terminated.
     53}}}
     545. Set output and installation directories and build.
     55{{{#!bash
     56export BUILD_OUTPUT_DIR=~/build/output
     57export BUILD_INSTALL_DIR=~/build/install
     58export BOOST_VERSION=1_51_0
     59export BOOST_BUILD_DIR=$BUILD_OUTPUT_DIR/boost_$BOOST_VERSION
     60export BOOST_INSTALL_DIR=$BUILD_INSTALL_DIR/boost_$BOOST_VERSION
     61mkdir -p $BOOST_BUILD_DIR
     62mkdir -p $BOOST_INSTALL_DIR
     63./b2 toolset=gcc --prefix=$BOOST_BUILD_DIR/build install
     64export PATH=$PATH:$BOOST_BUILD_DIR/build/bin
     65}}}
     661. '''mingw specific:''' Comment out the following line ( around line 486 ) in tools/python.jam:
     67`python-cmd = "$(python-cmd)" ;` It's within this if block:
     68{{{#!python
     69if [ version.check-jam-version 3 1 17 ] || ( [ os.name ] != NT )
     70}}}
     717. Now that the boost build system is built and installed, time to build the actual boost library binaries.
     72{{{#!bash
     73cd $BOOST_SRC_ROOT
     74b2  --build-dir=$BOOST_BUILD_DIR toolset=gcc --prefix=$BOOST_INSTALL_DIR install 2&gt;&amp;1 | tee $BOOST_BUILD_DIR/build.log
     75}}}
     76
     77That will build static and shared non-debug multi-threaded variants of the libraries. To build all variants, pass the additional option, `--build-type=complete1
     788. 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`.
     79'''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.
     80
     81
     82== Posix Build Specifics ( Ubuntu LTS 12.04 ) ==
     83To get boost to build without errors under Ubuntu LTS 12.04, you need to install the following additional libraries via apt-get:
     84
     851. python-dev
     861. libbz2-dev
     87
     88'''Update:''' Added posix build info.
     89
     90'''Update 2012-10-30:''' Fixed paths and added note to comment out line 489 in `tools/python.jam`