Friday, October 10, 2014

Building Boost Libraries quickly

Building Boost

Setting up your development environment

Linux:

1. Fedora/Centos:
You will need:
a. gcc-c++
b. libstdc++
c. libstdc++-devel
Do a yum install or find the rpms on the DVD / net.

2. If you're on *Ubuntu, do a sudo apt-get install of:
a. g++
b. libstdc++-dev
c. libstdc++
Version should be at least 4.8.x - or you'll miss out on the C++11 fun.

3. If you're on Ubuntu and want to try clang, sudo apt-get install the following:
a. clang
b. llvm
c. libc++-dev
Version should be preferably 3.4.

Windows:
If you're on Visual Studio, try to get Visual Studio 2012 or 2013 (Express Edition is free, I have the DVD image for 2013).

Building Boost
Download the boost source archive from boost.org (current version 1.56) and extract it in a directory. Call it <boostsrc>.


Linux:
$ cd <boostsrc>

$ sudo mkdir /opt/boost
$ chown <builduser>:<builduser> /opt/boost
$ ./bootstrap.sh
$ ./b2 install --build-dir=<buildarea> --prefix=/opt/boost --layout=tagged variant=debug,release link=shared runtime-link=shared threading=multi cxxflags="-std=c++11"

<builduser> is the user id of the logged on user.
<buildarea> is the directory where intermediate build products would be generated.

/opt/boost is where the end products would be installed.

Windows:

$ cd <boostsrc>

For 32-bit:
$ "C:\Program Files\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
or
$ "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86 


$ b2 install --libdir=<installdir>\libs --includedir=<installdir>\include --build-dir=<buildarea> --layout=tagged variant=debug,release threading=multi link=shared runtime-link=shared

For 64-bit:
$ "C:\Program Files\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
$ "C:\Program Files\Microsoft Visual Studio 12.0 (x86)\VC\vcvarsall.bat" x86_amd64
$ b2 install --libdir=<installdir>\libs --includedir=<installdir>\include --build-dir=<buildarea> --layout=tagged variant=debug,release threading=multi link=shared runtime-link=shared --address-model=64

<buildarea> is the directory where intermediate build products would be generated.
<installdir> is where you choose to install the products of the build.

No comments: