Visual Studio install boost library

boost是C++开发的一个第三方类库,并且是很重要的一个类库,下面简单讲述一下其安装和使用过程。

1 下载、安装

下载&&解压Boost libary
打开“Developer Command Prompt for VS2015” (PS:这个程序在哪个位置我也不知道,通过开始进行搜索,就ok了),定位到刚才解压的boost library目录下

$boostrap.bat
$b2.exe(ps:这个程序执行时间很长),执行完成后,会显示一下部分,这也就是我们下一步调用的关键
这里写图片描述

2 使用

新建 Win32 Console Application,其他使用默认参数
写一个测试函数,测试VS是否正常

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<stdlib.h>

int main()
{
    std::cout << "Hello,World!" << std::endl;
    system("pause");
    return 0;
}

将boost的相关文件夹添加到编译和链接路径:

Properties->C/C++ ->Additional Include libaries 将 E:\boost_1_63_0 加入编译路径;
Properties->Linker ->Additional Libraries Directories 将 E:\boost_1_63_0\stage\lib加入链接路径;

编写下面代码进行测试:

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<stdlib.h>
#include<boost\regex.hpp>

int main()
{
    std::string line = "Subject:Re:You have installed boost successfully.";
    boost::regex pat("^Subject:(Re:|Aw: )*(.*)"); \
        boost::smatch matches;
    if (boost::regex_match(line, matches, pat)) {
        std::cout << matches[2] << std::endl;
    }
    system("pause");
    return 0;
}

这里写图片描述

ok!

参考地址:
https://www.youtube.com/watch?v=GOhHMS4I9Zw

猜你喜欢

转载自blog.csdn.net/guchuanhang/article/details/54312850