Build QuantLibXL From Source Code

This document explains how to build QuantLibXL and its prerequisites from source code.

If you want a binary installation of the precompiled addin, go instead to the QuantLibXL web site.

For other tutorials which explain how to compile QuantLibAddin for platforms other than Microsoft Excel on Windows, return to the Tutorials index.

1 Choose a Build - Basic or Full
2 Prerequisites
3 A Note on Directories
4 Install the Source Code
5 Build QuantLibXL

1 Choose a Build - Basic or Full

This tutorial offers a choice of two builds as summarized below.

BuildDescription
Full This build performs autogeneration of QuantLibXL source code. Requires you to install Python and gensrc. You can enhance/customize this build by editing addin XML metadata and re-running gensrc.
Basic For this build, the autogenerated source code has already been created for you, and is not recreated during the build. Does not require Python or gensrc. To customize/enhance this build you would need manually to edit the autogenerated C++ source files.

2 Prerequisites

Before proceeding to compile the source code, consult the documents below.

2.1 Conventions

See the following document regarding naming conventions in use for the project: Conventions

2.2 Boost

QuantLibXL depends on Boost. Any recent version of Boost should be OK. You will need the compiled Boost libraries, the Boost header files alone are not sufficient.

2.3 Python 3.x

For the Full build, some code is autogenerated by gensrc, which is a Python script. Before rebuilding QuantLibXL you need to have Python 3.x installed on your machine. Here is the link to the Python website: http://www.python.org/.

If Python is installed on your machine so that .py files are associated with the Python executable, then the gensrc scripts should build OK with no modification required.

Otherwise, after you install gensrc (below), you might need to edit these files...

    ObjectHandler\gensrc\Makefile.vc
    QuantLibAddin\gensrc\Makefile.vc

...and set the PYTHON variable equal to the location of the Python executable on your machine, e.g:

    PYTHON=C:\Users\username\AppData\Local\Programs\Python\Python39\python.exe

3 A Note on Directories

You are now ready to proceed with the build. You need to install the following projects:

  • QuantLib 1.22.0 - The core C++ analytics library
  • ObjectHandler 1.22.0 - An object repository
  • log4cxx 0.10.0f14 - A logging framework, used by ObjectHandler
  • QuantLibAddin 1.22.0 - Addins for QuantLib functionality
  • QuantLibXL 1.22.0 - The Excel implementation of QuantLibAddin
  • gensrc 1.22.0 - A Python application for autogenerating source code (Full build only)

The build uses a VC solution (see below) which allows QuantLibXL and its prerequisites to be compiled together. The solution uses relative pathnames to refer to the prerequisite projects QuantLib, log4cxx, ObjectHandler, QuantLibAddin, and (for the Full build only) gensrc. In order for this to work, these projects must reside side by side in the directory tree, and the name of each project's parent directory must not include the version number (e.g. QuantLib not QuantLib-1.22.0).

Create a new empty folder on your hard drive to serve as the root directory for the build. You can use any path, for purposes of this tutorial the build directory is C:\build_ql_1_22_0. As described below you should copy all of the required source code zip files to that directory and then unzip them in place. After unzipping QuantLib you must manually rename the target directory, removing the 1.22.0 suffix from the directory name. After all of the source code is unzipped you should have the following directory structure:

C:\build_ql_1_22_0\gensrc (required only for the Full build)
C:\build_ql_1_22_0\log4cxx
C:\build_ql_1_22_0\ObjectHandler
C:\build_ql_1_22_0\QuantLib
C:\build_ql_1_22_0\QuantLibAddin
C:\build_ql_1_22_0\QuantLibXL

4 Install the Source Code

Go to the QuantLib downloads page.

Download QuantLib-1.22.0.zip and uncompress the package to C:\build_ql_1_22_0\QuantLib.

Go to the QuantLibXL downloads page.

Download log4cxx-0.10.0f14.zip and uncompress the package to C:\build_ql_1_22_0\log4cxx.

Download ObjectHandler-1.22.0.zip and uncompress the package to C:\build_ql_1_22_0\ObjectHandler.

Download QuantLibAddin-1.22.0.zip and uncompress the package to C:\build_ql_1_22_0\QuantLibAddin.

Download QuantLibXL-src-1.22.0.zip and uncompress the package to C:\build_ql_1_22_0\QuantLibXL.

Full build only - download gensrc-1.22.0.zip and uncompress the package to C:\build_ql_1_22_0\gensrc.

5 Build QuantLibXL

Basic build - open VC solution QuantLibXL\QuantLibXL_basic.sln.

Full build - open VC solution QuantLibXL\QuantLibXL_full.sln.

Choose configuration Release (static runtime) and do Build | Build Solution.

The build process creates the QuantLibAddin XLL file QuantLibXL\xll\QuantLibXL-vc??-mt-s-1_22_0.xll. Instructions for loading the addin are provided in the QuantLibXL installation document: http://www.quantlibxl.org/installation.html