Compiling Boost libraries on Mac/Linux

1. Download/checkout the boost source code. Let's say we are downloading it at /opt/boost directory
>cd /opt/boost
>svn co http://svn.boost.org/svn/boost/trunk boost-trunk
2. Download following external source libraries at /opt/boost directory and unzip and compile them.
a. bzip
b. expat
c. icu
d. zlib
3. cd to boost-trunk directory and run ./bootstrap.sh (you might have to execute chmod 755 bootstrap.sh)
4. Below is the script which sets the environments and compiles the boost libraries.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/local/lib:/usr/lib:.
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
export BOOST_BIN_ROOT=/opt/boost/boost-binary
export BOOST_INSTALL_DIR=/opt/boost/boost-trunk
export PATH=$PATH:/opt/boost/bjam
export EXPAT_INCLUDE=/opt/boost/expat/include
export EXPAT_LIBPATH=/opt/boost/expat/lib
export HAVE_ICU=1
export BZIP2_SOURCE=/opt/boost/bzip2-1.0.5
export ZLIB_SOURCE=/opt/boost/zlib-1.2.3
export ICU_PATH=/opt/boost/icu/source
cd $BOOST_INSTALL_DIR
bjam threading=multi variant=release link=shared --build-dir=$BOOST_BIN_ROOT --prefix=$BOOST_INSTALL_DIR --without-mpi toolset=darwin install

5. If you want to compile specific library, replace bjam command from above script
bjam threading=multi variant=release link=shared --with-$1 --build-dir=$BOOST_BIN_ROOT --prefix=$BOOST_INSTALL_DIR toolset=darwin install

Here in --with-$1 where $1 would be your library name.

No comments:

Post a Comment