QuantLib installation on Mac OS X

Jack Harvard

Boost Installation

First, get MacPorts (http://www.macports.org/). Optionally, Porticus (http://porticus.alittledrop.com/) is a nice gui to use.

To install boost, run in Terminal:

sudo port install boost
Boost should install in /opt/local by default.

QuantLib Installation

Download QuantLib from its download page on SourceForge, located at http://sourceforge.net/projects/quantlib/files/. You want to download the tar.gz package (at the time of this writing, 1.0.1 is the latest version) and extract it by running

tar xzvf QuantLib-1.0.1.tar.gz
in Terminal. To install QuantLib, enter the folder you just created:
cd QuantLib-1.0.1
and run:
./configure --enable-static --with-boost-include=/opt/local/include/ \
            --with-boost-lib=/opt/local/lib/ --prefix=/opt/local/
(mind the backslash on the end of the first line; it tells the terminal to continue on the next line. You might also discard the backslash and write the whole command on a single line.)

Finally, run:

make && sudo make install
and then try to compile the examples. For example,
g++ -I/opt/local/include/ -I/opt/local/include/boost BermudanSwaption.cpp \
    -o bermudanswaption -L/opt/local/lib/ -lQuantLib

The whole process takes two hours if installing both Boost and QuantLib.

Appendix: Boost Configuration

If you want to make the Boost headers and libraries available to all C++ projects, edit ~/.bash_profile and add the following lines into the file:

export CPLUS_INCLUDE_PATH=/opt/local/include
export C_INCLUDE_PATH=/opt/local/include
export DYLD_LIBRARY_PATH=/opt/local/lib
When this is done, restart the terminal. After this, no include (-I) or link (-L) directory needs to be specified when compiling with g++.