# Windows

### 前期准备

* C++编译器，建议Visual Studio 2015
* python，推荐使用Ananconda
* cmake >= 3.0.0
* boost >= 1.58.0

### 编译指令

{% hint style="info" %}
下面的指令请在visual studio命令行中运行，确保在命令行中可以运行编译器cl和msbuild。
{% endhint %}

```
build_windows.bat
```

用户可以看到，在`build_windows.bat`文件的头部，有以下参数变量需要设置：

```
set BOOST_ROOT=D:\dev\boost_1_65_1
set BOOST_LIBRARYDIR=D:\dev\boost_1_65_1\lib64-msvc-14.0
set INCLUDE=%BOOST_ROOT%;D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
set QL_DIR=%CD%\QuantLib
set QLEXT_DIR=%CD%\QuantLib-Ext
set BUILD_TYPE=Release
set ADDRESS_MODEL=Win64
set MSVC_RUNTIME=dynamic
set VS_VERSION=Visual Studio 14 2015
```

其中：

* BOOST\_ROOT：boost的根目录
* BOOST\_LIBRARYDIR：boost库文件根目录
* INCLUDE：c/c++编译器的头文件寻找目录
* QL\_DIR：quantlib项目根目录
* QLEXT\_DIR：quantlibext项目根目录
* BUILD\_TYPE：编译类型
* ADDRESS\_MODEL：32位或者64位选择
* MSVC\_RUNTIME：c/c++运行时链接类型
* VS\_VERSION：Visual Studio版本

大部分变量只需保留原值，一般来说用户只需指定下面的变量指向正确的位置：

```
set BOOST_ROOT=D:\dev\boost_1_65_1
set BOOST_LIBRARYDIR=D:\dev\boost_1_65_1\lib64-msvc-14.0
set INCLUDE=%BOOST_ROOT%;D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
```

### 调试方法

同样的按照上面的方法编译，只是需要将编译类型改为调试模式：

```
set BUILD_TYPE=Debug
```

在编译完成以后，我们就得到了带debug信息的可运行文件。这个时候就可以使用各种熟悉的可视化工具进行debug。下面我们以Visual Studio Code为例，介绍如何进行debug。

* 在Visual Sutdio Code中打开项目目录：

![](https://2237633300-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LIdofm24X5OklALN1Xn%2F-LJHosyFlx4TGHxVIC-9%2F-LJHxZhhgF7eAX8JTbdH%2F%E6%8D%95%E8%8E%B711.PNG?alt=media\&token=be8b744d-3e3a-4123-818f-e4cf01321f51)

* 安装c/c++编译调试组件，安装完成后重启编辑器

![](https://2237633300-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LIdofm24X5OklALN1Xn%2F-LJHosyFlx4TGHxVIC-9%2F-LJHxqP2r4rnOWIEp1Se%2F%E6%8D%95%E8%8E%B712.PNG?alt=media\&token=4c883cf0-43d0-48df-83e5-f93e018b293b)

* 配置调试

假设我们要调试QuantLib/examples/Bonds的例子，我们在debug窗口下创建新的配置：

![](https://2237633300-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LIdofm24X5OklALN1Xn%2F-LJHyWZiGegSWjDyv4Xf%2F-LJHyy8JgqIByhTqNXoP%2F%E6%8D%95%E8%8E%B713.PNG?alt=media\&token=30515261-a084-422e-8c29-b0cf37a0af2d)

选择c/c++(windows)

![](https://2237633300-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LIdofm24X5OklALN1Xn%2F-LJHyWZiGegSWjDyv4Xf%2F-LJHzSJMenFpswVqiHG4%2F%E6%8D%95%E8%8E%B714.PNG?alt=media\&token=87ea1805-6623-467b-9ccc-a4794b09e499)

\
输入配置信息，例如：

```
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息，请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "example_bond",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/QuantLib/build/examples/Bonds/Debug/Bonds.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }
    ]
}
```

最重要的是上面的program信息，需要指向需要调试的可运行文件，然后保存。

* 设置断点调试

在QuantLib/example/Bonds.cpp文件中设置断点，然后启动调试器：

![](https://2237633300-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LIdofm24X5OklALN1Xn%2F-LJI-Q7sxOpvUSRhgVQV%2F-LJI0HJBSn39OapWB3pP%2F%E6%8D%95%E8%8E%B715.png?alt=media\&token=b88da3fe-adfc-4f1b-90e3-3c6a942d27ec)

即可进入调试：

![](https://2237633300-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LIdofm24X5OklALN1Xn%2F-LJI-Q7sxOpvUSRhgVQV%2F-LJI0YBeBbHrr6KSOMqT%2F%E6%8D%95%E8%8E%B716.png?alt=media\&token=db22e824-eaab-4660-b6bc-217be4590196)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dxzq.gitbook.io/worklist/qlengine/qlengine-bian-yi-yi-ji-tiao-shi/windows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
