QuantLib installation on Mac OS X
To install boost, run in Terminal:
sudo port install boostBoost should install in /opt/local by default.
Alternatively, you can use Homebrew (http://brew.sh/). Homebrew installs in /usr/local instead.
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.8 is the latest version) and extract it by running
tar xzvf QuantLib-1.8.tar.gzin Terminal. To install QuantLib, enter the folder you just created:
On Mac OS X 10.9 (Mavericks) and later, you'll need to pass additional environment variables to ./configure (thanks to Albert Azout for pointing it out). Run:
./configure --with-boost-include=/opt/local/include/ \ --with-boost-lib=/opt/local/lib/ --prefix=/opt/local/ \ CXXFLAGS='-O2 -stdlib=libstdc++ -mmacosx-version-min=10.6' \ LDFLAGS='-stdlib=libstdc++ -mmacosx-version-min=10.6'(mind the backslash on the end of the lines; 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.) If your Boost installation is not in /opt/local, change the paths above accordingly.
On earlier systems, it's not necessary to pass environment variables, so the command can be simplified to:
./configure --with-boost-include=/opt/local/include/ \ --with-boost-lib=/opt/local/lib/ --prefix=/opt/local/Again, if your Boost installation is not in /opt/local, change the paths above accordingly.
make && sudo make installand then try to compile the examples. For example,
cd Examples/BermudanSwaption g++ -I/opt/local/include/ -I/opt/local/include/boost BermudanSwaption.cpp \ -o bermudanswaption -L/opt/local/lib/ -lQuantLib
The whole process can take a couple of 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/libWhen this is done, restart the terminal. After this, no include (-I) or link (-L) directory needs to be specified when compiling with g++.