Writing Your First QuantLib Program in C++ – From First Principles 您所在的位置:网站首页 quantlib Writing Your First QuantLib Program in C++ – From First Principles

Writing Your First QuantLib Program in C++ – From First Principles

#Writing Your First QuantLib Program in C++ – From First Principles| 来源: 网络整理| 查看: 265

Introduction

In the previous post we unpacked, bootstrapped and built both Boost and QuantLib for Visual Studio 2017. Now we will show how to use it!

In addition, this post will cover the issues and errors that I encountered when I first attempted this. We will look at how to correctly declare and instantiate objects and variable types by peeking at their class headers.

Creating the Test Project

Begin by opening up Visual Studio 2017 and create a New Project. Under Visual C++ create a new Windows Console Application. I called mine ‘Test”. Click OK. Once the Solution opens up you will notice two files: “pch.cpp” and “Test.cpp”. Ignore pch.cpp, that’s just for PreCompiled Headers, you’ll be doing your programming in Test.cpp.

Before we start you will need to include the QuantLib libraries. You will not need to include the Boost libraries due to the nature of how we installed it. To see this, right-click on the Test project in the Solution Explorer.

TestProjectSolutionExplorer

and click Properties (right down the bottom), or simply click on Test and then hold Alt+Enter.

Under Configuration Properties > VC++ Directories you should notice that Boost has included itself already! If Boost is not showing up here, you will need to attempt to re-install Boost by following the instructions in the previous post.

TestProjectBoostIncludedBoost is good enough to include itself in your C++ projects. Thanks Boost!

To include QuantLib click on Include Directories then click the Plus Folder button and navigate the browser to the Root QuantLib Directory:

TestProjectIncludeQuantLibThe Include Directory should point to the root folder of QuantLib (the folder containing lib etc…)

Then for Library Directories do the same but this time click on the Lib subfolder (making sure not to drill down any further in to the directory!):

TestProjectLibraryQuantLibThe Library Directory should point to the Lib subfolder.

Your VC++ Directories should now look like this:

TestProjectPropertyPagesThis is what your VC++ Directories properties should look like after including QuantLib.

Let’s try it out. Go back to your Solution and double-click to open Test.cpp. At the very top, just below the two include instructions already there, type in #include If you have built QuantLib and Included it correctly, typing in #include followed by



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有