安装Boost

来源:互联网 发布:java与javascript区别 编辑:程序博客网 时间:2024/06/16 06:52

一, 安装Boost开发环境

到Boost官网下载boost_1_64_0.zip 这是官网的地址

下载过后安装Boost

在DOS在Boost

可以发现解压后的文件中有一个bootstrap.bat文件。
运行bootstrap.bat

之后会新生成了一个bjam.exe文件
在命令窗口中输入语句:bjam.exe。

这是效果图
boost

二,配置项目的环境

添加boostest工程的包含目录和库目录

包含目录添加 C:\Boost\boost_1_64_0

库目录添加 C:\Boost\boost_1_64_0\stage\lib
Boost_VS

具体如下图
VS_include

VS_lib

三,测试程序

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>#include <boost/lexical_cast.hpp>   #include <iostream>using namespace std;int main(void){    using boost::lexical_cast;    int a = lexical_cast<int>("123");    double b = lexical_cast<double>("123.0123456789");    string s0 = lexical_cast<string>(a);    string s1 = lexical_cast<string>(b);    cout << "number: " << a << "  " << b << endl;    cout << "string: " << s0 << "  " << s1 << endl;    int c = 0;    try {        c = lexical_cast<int>("abcd");    }    catch (boost::bad_lexical_cast& e) {        cout << e.what() << endl;    }    printf("\n");    system("pause");    return 0;}

运行效果图
这里写图片描述

原创粉丝点击