boost 入门

官网下载boost1.60.0-msvc14-32.exe
安装:
预先安装msvc14
直接安装

安装结束:
双击bootstrap.bat
在切换到解压安装目录

bjam -j4 --debug-symbols=on --build-type=complete toolset=msvc-14.0 threading=multi runtime-link=shared address-model=32

对于boost 来说,很多库都是.hpp格式,仅包含头文件即可!!不需要静态库!而静态库在./stage/lib/.不是./lib32-msvc-14.0/文件下, 也不是/libs/

上一步编译结束后,会有如上提示。
定义包含路径D:\boost_1_60_0;
定义是否包含预定义头文件In Configuration Properties > C/C++ > Precompiled Headers, change Use Precompiled Header (/Yu) to Not Using Precompiled Headers
入门可以参考文件下的index.html 说明

使用vs2015 跑一个小例子:

#include <boost/version.hpp>
#include <boost/config.hpp>
#include <iostream>

using namespace std;

int main()
{
    cout << BOOST_VERSION << endl;
    cout << BOOST_LIB_VERSION << endl;

    cout << BOOST_PLATFORM << endl;
    cout << BOOST_COMPILER << endl;
    cout << BOOST_STDLIB << endl;   

}

2

#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " ");
}

3

#include <boost/lexical_cast.hpp>  
//这里目录明明是lexical_caset_old.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;
}

当需要库lib的时候,可能还需要指定dll 拷贝到./windows/sysWOW64

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值