boost——windows下VS2013update5编译boost库

8 篇文章 0 订阅
3 篇文章 0 订阅

下载boost库

http://www.boost.org上下载到目前最新的boost库
注意,现在最新版的需要编译器支持C++14,可以用VS2013 update5,或者下载最新版的VS2017

得到源代码之后,使用vs2013的cl.exe编译

这里写图片描述
这里写图片描述
进入到源代码目录中

建立编译工具bjam.exe—-需要执行bootstrap.bat

这里写图片描述

指定编译命令

指定msvc版本12.0对应的是vs2013,–stagedir是指定编译后存放的目录

bjam stage --toolset=msvc-12.0 --stagedir="E:\Library\boost\boost_1_64_0" link=static runtime-link=shared runtime-link=static threading=multi debug release  

这里写图片描述
等一会儿 就能编译完成~

开始使用boost

首先需要设定文件包含目录:
这个是源代码的目录
这里写图片描述

设定库目录:
这里写图片描述
然后建立我们的第一个boost项目,代码如下:

#include <boost/lexical_cast.hpp>    
#include <iostream>    

using namespace std;

int main()
{
    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;
    }

    return 0;
}

这里写图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值