Build boost in Windows7 64bit VS2013

一、背景

最近在一周在做自然场景中图像文本检测和识别相关的工作,图像中文本检测阶段完成80%,识别部分准备用一下谷歌的TensorFlow框架。考虑到,后期用于训练图像C++代码部分会用到boost库,所以今天就试着下载和编译一下boost.

二、编译步骤

  1. Boost官网下载,Boost1.61.0.
  2. 解压下载文件boost_1_61_0.zipD:/ProgramFiles.
  3. D:\ProgramFiles\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts中启动双击VS2013 x64 兼容工具命令提示快捷方式
  4. 在Windows命令行模式, 切换到D:/ProgramFiles/boost_1_61_0.

    D:\ProgramFiles\Microsoft Visual Studio 12.0\VC\bin\x86_amd64>D:
    D:\>cd ProgramFiles\boost_1_61_0
    D:\ProgramFiles\boost_1_61_0>bootstrap vc12
    ...
    D:\ProgramFiles\boost_1_61_0>.\b2 --address-model=64 -j4
    ...
    ...updated 1136 targets...
    The Boost C++ Libraries were successfully built!
    The following directory should be added to compiler include paths:
    D:\ProgramFiles\boost_1_61_0
    The following directory should be added to linker library paths:
    D:\ProgramFiles\boost_1_61_0\stage\lib
    D:\ProgramFiles\boost_1_61_0>

三、编译问题


  1. bootstrap fatal error C1034: ctype.h: 不包括路径集
    解决方法:

在系统的环境变量中, 添加 C:\Windows\System32
重启电脑。

四、测试demo

demo1

#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) << " ");
}
解决方案平台解决方案配置demo运行状态
Win32Debugpass
Win32Releasepass
x64Debugpass
x64Releasepass

demo2

#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;
}
解决方案平台解决方案配置demo运行状态
Win32Debugpass
Win32Releasepass
x64Debugpass
x64Releasepass

demo3

#include <string>
#include <iostream>
#include <boost/regex.hpp>

int main()
{
    std::string line;
    boost::regex pat("^Subject: (Re: |Aw: )*(.*)");

    while (std::cin)
    {
        std::getline(std::cin, line);
        boost::smatch matches;
        if (boost::regex_match(line, matches, pat))
            std::cout << matches[2] << std::endl;
    }
}
解决方案平台解决方案配置demo运行状态
Win32Debugfail
Win32Releasepass
x64Debugfail
x64Releasefail
  • 测试结果

    1. 在C++项目release文件夹中创建jayne.txtjayne.txt中内容如下:
    To: George Shmidlap
    From: Rita Marlowe
    
    Subject: Will Success Spoil Rock Hunter?
    ---
    
    See subject.
    1. Windos命令切换到C++项目release文件内,运行类似以下命令:
      example.exe < jayne.txt

    输出结果:
    Will Success Spoil Rock Hunter?

参考

[1] vs2013 boost 安装问题若干
[2] Boost的VS开发环境搭建
[3] Boost-invocation

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Digital2Slave

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值