Boost for Windows
Introduction
Boost is a collection of C++
libraries. These notes describe a Slackware package of these libraries
for use when cross-building for MS Windows using MinGW-w64.
Using the package
The package is installed as usual:
installpkg
boostMSW-1.54.0-i386-2fog.tgz
Everything is installed under /usr/local/opt/boostMSW.
The libraries are installed under /usr/local/opt/boostMSW/lib.
They are all static libraries.
To cross-compile code using Boost, you will need to pass the option '-I/usr/local/opt/boostMSW/include'
to the MinGW-w64 compiler (i686-mingw32-g++).
To cross-link code using Boost, you will need to pass the option '-L/usr/local/opt/boostMSW/lib'
to the minGW compiler (i386-mingw32-g++),
and a '-l' option for each
Boost library that you are using (e.g. '-lboost_thread_win32' for
the thread library). Note that the MSW versions of some of the Boost
libraries
have slightly different names from the Linux versions (e.g. the Linux
version of thread library is called boost_thread). Since the
libraries are static, the '-l'
options must follow the .o
filenames on the command line, otherwise the libraries will not be
searched correctly.
Building the package
The Boost source was downloaded from http://www.boost.org/users/history/.
Version 1.54.0 was used, since this is the version supplied with
Slackware 14.1.
The source was cross-compiled using MinGW-w64, since this should ensure
that the libraries will be consistent with our own cross-compiled code
(e.g. for threading model, exception handling, etc.).
Boost uses its own build tool (b2)
instead of make - figuring out the options to use to cross-compile
involved lots of Googling and experimentation. The following were the
most useful references (but they are all out-of-date, or incomplete, or
misleading, or inappropriate, or some combination thereof!):
The following steps were used to build the package:
cd
tools/build/v2/
./bootstrap.sh
./b2 install --prefix=/home/boxer/boost.build
export PATH=/home/boxer/boost.build/bin:$PATH
cd ../../..
BUILD_DIR=/home/boxer/boost
mkdir $BUILD_DIR
export
PATH=/usr/local/opt/mw32/bin/:/usr/local/opt/mw32/i686-w64-mingw32/bin/:$PATH
echo "using gcc : : i686-w64-mingw32-g++ : ;" >user-config.jam
b2 \
--build-dir=$BUILD_DIR/build \
--stagedir=$BUILD_DIR \
--user-config=user-config.jam \
--without-mpi \
--without-python \
--layout=system \
-sNO_BZIP2=1 \
target-os=windows \
variant=release \
link=static \
runtime-link=shared \
threading=multi \
threadapi=win32 \
stage
INSTALL_DIR=/home/boxer/boost.install
mkdir -p $INSTALL_DIR/usr/local/opt/boostMSW
b2 \
--build-dir=$BUILD_DIR/build \
--stagedir=$BUILD_DIR \
--user-config=user-config.jam \
--without-mpi \
--without-python \
--layout=system \
-sNO_BZIP2=1 \
target-os=windows \
variant=release \
link=static \
runtime-link=shared \
threading=multi \
threadapi=win32 \
--prefix=$INSTALL_DIR/usr/local/opt/boostMSW
install
cd $INSTALL_DIR
mkdir install
vim install/slack-desc
su
makepkg /usr/local/packages/boostMSW-1.54.0-i386-2fog.tgz