Writing Your First QuantLib Program in C++ – From First Principles | 您所在的位置:网站首页 › quantlib › Writing Your First QuantLib Program in C++ – From First Principles |
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 ProjectBegin 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. 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. ![]() To include QuantLib click on Include Directories then click the Plus Folder button and navigate the browser to the Root QuantLib Directory: ![]() 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!): ![]() Your VC++ Directories should now look like this: ![]() 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 实验室设备网 版权所有 |