QuantLib installation in VC++

Dominik Holenstein

Based on the VC++ 2008 instructions by Dimitri Reiswich

These are step-by-step instructions to install QuantLib and Boost on the Microsoft Visual C++ 2010 IDE. They work on later versions of Visual C++ as well (you can download the latest free Community edition on the Microsoft web site). Earlier versions of the compiler are no longer supported by QuantLib.

I tried to include almost every step in the installation procedure. Something that is obvious to one person might not be obvious to someone else. The only thing that I assume you have on your computer is the Visual C++ 2010 IDE (VC10).

Before using QuantLib you need to install the Boost library on your computer. Detailed instructions follow in the next section.

Boost Installation

We use the binary installer provided by the Boost project, that can be downloaded at http://sourceforge.net/projects/boost/files/boost-binaries/.

You'll have to enter the folder corresponding to the release you want to download (at the time of this writing, the latest version is Boost 1.55.0) and then choose the installer corresponding to your compiler and platform; for instance, boost_1_55_0-msvc-10.0-64.exe for Visual C++ 10 on a 64-bit system. Download and run the installer. The rest of this tutorial was written a while ago and assumes that you installed Boost 1.47 into the C:\Program Files\Boost\boost_1_47 folder; replace that with whatever folder the installer creates for your newer version (for instance, C:\Boost\boost_1_55_0).

Boost and QuantLib Installation

Here are the steps to make the installed Boost libraries available to QuantLib:

1. Open VC10 and make sure you have activated the expert settings. Go to Tools/Settings and make sure "Expert Settings" is checked. This might not be necessary in recent Visual C++ versions.

2. If you haven't downloaded QuantLib yet, go to its release page on GitHub.

3. Find the latest version and download the zip archive to your local drive. Unzip the file wherever you want; in the following, we'll assume that the QuantLib directory is C:\Program Files\QuantLib.

4. Open the QuantLib folder, then open the Visual Studio solution called QuantLib.sln by double clicking it. Choose Release from the configuration menu in the toolbar.

5. Open the Property Manager by clicking on View/Property Manager (or View/Other Windows/Property Manager, depending on your version of Visual Studio) and activate it. Expand the project node of QuantLib in the Property Manager and then the Configuration/Platform nodes (see screenshot below).

Earlier Visual C++ versions used Microsoft.cpp.<Platform>.users files for global settings. However, these files are now deprecated and, depending on your Visual C++ version, might no longer be available. If that is the case, or if you want to follow Microsoft's advice anyway, create a new property page as described at this link, add it to all projects in the solution, and use that instead of the .users files.

Select any of the new or global pages (or multi-select them all), right-click, and select Properties to bring up the property page window.


6. In the property page window, click on VC++ Directories on the left pane and add the paths for the Boost directories in Include Directories and Library Directories in the right pane. If you installed Boost in C:\Program Files\boost\boost_1_47, you'll have to add C:\Program Files\boost\boost_1_47 to the include directories. In earlier Boost version, the folder to add to the library directories was called C:\Program Files\boost\boost_1_47\lib. In later versions, the folder has a name such as C:\Program Files\boost\boost_1_63_0\lib32-msvc-10.0 or C:\Program Files\boost\boost_1_63_0\lib64-msvc-12.0 which includes compiler and build information; if you installed multiple ones, choose the one corresponding to your configuration. Click the OK button to set your changes.


7. Switch back to the Solutions Explorer, right-click on the solution icon and choose Build Solution to build all projects. Besides QuantLib, this will build the examples and run the test suite. The process takes a while (it took 1h and 7 minutes to build QuantLib and run the tests on a three-years old WinXP notebook with 3 GB RAM and a 2 GHz Intel dual core processor).


After finishing, the output should show no errors:

14>  Test suite "Master Test Suite" passed with:
14>    1703 assertions out of 1703 passed
14>    460 test cases out of 460 passed
14>  Tests completed in 29 m 8 s
========== Build: 15 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

You are done with building QuantLib. If you want, you can build the Debug version in the same way by choosing Debug from the configuration menu as shown below. This will allow you to debug your application later.


Quantlib Usage

As an example of QuantLib usage, I create a QuantLibTest folder in the C:\Program Files\QuantLib folder and set up a Win32 Console Application in Visual Studio by clicking File/New Project/Win32 Console Application.

New Project

I've chosen the project name TestingQuantLib, then I clicked on OK. Click on the Next button on the Win32 Application Wizard. Choose "Console application" as application type and check "Empty project" in the additional options. Click on Finish.


Choose, for example, the Release mode for that project. Note that very often, users don't setup a project correctly since they build QuantLib in one mode and try to call it from a test program which runs in some other mode. If you built QuantLib in release mode, you should build your project in release mode. If you build your project in debug mode without ever building QuantLib in debug mode, you'll have link errors.

To tell your project where to find QuantLib, open the project properties by right-clicking on the project icon in the IDE.

Open Project

Go to VC++ Directories. You can see that the Boost folders are already there, so you don't have to do anything to configure them.


Add the QuantLib path (C:\Program Files\QuantLib in this example) to the include directories. The result should be as shown below.

QuantLib include directory

Finally, you can add the QuantLib library path C:\QuantLib\QuantLib-0.9.7\lib to the library directories, or you can go to Configuration Properties/Linker/General and add it to Additional Library Directories. Click OK.

QuantLib library dir

To test if the setup works, add the following program to the TestingQuantLib project. The program tests some Date and Calendar classes.

#include <ql/quantlib.hpp>
#include <iostream>

int main()
        QuantLib::Calendar myCal=QuantLib::UnitedKingdom();
        QuantLib::Date newYearsEve(31,QuantLib::Dec,2008);

        std::cout << "Name: "                       << myCal.name()<< std::endl;
        std::cout << "New Year is Holiday: "        << myCal.isHoliday(newYearsEve)<< std::endl;
        std::cout << "New Year is Business Day: "   << myCal.isBusinessDay(newYearsEve)<< std::endl;

        std::cout << "--------------- Date Counter --------------------" << std::endl;

        QuantLib::Date date1(28,QuantLib::Dec,2008);
        QuantLib::Date date2(04,QuantLib::Jan,2009);

        std::cout << "First Date: "            << date1 << std::endl;
        std::cout << "Second Date: "           << date2 << std::endl;
        std::cout << "Business Days Betweeen: "<< myCal.businessDaysBetween(date1,date2) << std::endl;
        std::cout << "End of Month 1. Date: "  << myCal.endOfMonth(date1) << std::endl;
        std::cout << "End of Month 2. Date: "  << myCal.endOfMonth(date2) << std::endl;

        double tmp;
        std::cin >> tmp;

        return 0;

Hit F5 to run the program. The output of the program should be:

Program output

One last thing: If you see some warnings after building, to get rid of them open the project properties again, go to Configuration Properties/C/C++/Preprocessor/Preprocessor Definitions and add _SCL_SECURE_NO_DEPRECATE and _CRT_SECURE_NO_DEPRECATE to the definitions, as shown here:

Preprocessor defs

Now, building the TestingQuantLib project again shouldn't show you any warnings anymore, just as in the Output window below.

Test output

We're done!