C++ boost库安装

Boost是C++中的库,和标准库(STC)类似的,包含许多包和函数可以直接调用

  1. 下载Boost库

    在Boost库官网上下载最新版本,下载地址

  2. 编译

    (1)将Boost压缩包解压

    (2)打开VS提供的CL工具,x64_x86 cross Tools Commadn Prompt for VS 2019

    (3)切换到boost解压的目录中

    (4)执行以下命令:

    1
    2
    .\bootstrap.bat
    .\b2.exe

    (注意,b2 是 bjam的升级版,直接使用b2进行安装即可)

    (5)编译需要5到10分钟,编译后的目录在cmd的最后有显示

    image-20200606120413396

  3. 连接到VS编译器

    打开VS2019,新建测试项目

    项目—属性中,将编译后的目录添加进去

    (1)C/C++ —常规中,附加包含目录,将第一个目录添加进去

    image-20200606120755909

    (2)链接器—附加库目录,将第二个目录添加进去

    image-20200606120809555
  4. 测试Boost

    测试代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    #include <iostream>
    #include <boost/sort/sort.hpp>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main()
    {
    vector<int> arr;
    while (arr.size() < 100) arr.push_back(std::rand());
    boost::sort::block_indirect_sort(std::begin(arr), std::end(arr));
    for_each(std::begin(arr), std::end(arr), [](int& a) {
    cout << a << "\t";
    });
    return 0;
    }

Note:

另一种安装方式,直接下载window对应的二进制安装包,也就是msi包,在boost_1.71下有window安装包

但是安装后,连接的库目录是

1
D:\boost_1_71_0\lib64-msvc-14.2

(取决于安装的路径和VS的版本)

You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You need to set client_id and slot_id to show this AD unit. Please set it in _config.yml.