前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Windows下Boot的编译和使用

Windows下Boot的编译和使用

作者头像
卡尔曼和玻尔兹曼谁曼
发布2019-01-22 10:40:58
7780
发布2019-01-22 10:40:58
举报

1。首先在Boost的官网下载Boot源码,分为Windows版本和Linux版本。下载好以后进行加压(我的解压目录是:E:\C++\Library\boost_1_62_0)。

2。Windows下Boot的编译需要根据自己的Visual Studio版本,然后选择编译(x86,x64)版本,以及(Debug,Release)版本。我自己的是VS2013。从开始菜单打开VS的Tools Command Prompt进行编译。我编译的是VS2013的x86版本。所以打开VS2013 x86 Native Tools Command Prompt。

3。 使用cd命令切换目录到到解压好的Boot。运行bootstrap.bat命令,会生成一个b2.exe。

4。 运行./b2 —toolset=msvc-12.0进行编译。(运行./b2 –help可以查看编译相关的选项)。因为我的是VS2013对应的就是msvc-12.0。根据自己的实际情况调整。

编译好了以后,打开VS使用Boost进行开发。 首先设置Include文件目录:依次点开Properties->C/C++->Additional Include Directories添加E:\C++\Library\boost_1_62_0 然后设置lib文件目录:依次点开Properties->Linker->Additional Library Directories添加E:\C++\Library\boost_1_62_0\stage\lib

下面是一个filesystem的入门程序:

代码语言:javascript
复制
#include <iostream>
#include <string>
#include "boost\filesystem.hpp"

using namespace boost;
using std::cout;
using std::string;


int main()
{
    string fileName("C:\\Users\\theone\\Desktop\\readme.txt");
    auto filePath = filesystem::path(fileName);

    if (filesystem::exists(filePath))    // 判断该path是否存在
    {
        if (filesystem::is_regular_file(filePath))        // 判断该path是不是一个普通文件
            cout << filePath << " size is " << filesystem::file_size(filePath) << '\n';

        else if (filesystem::is_directory(filePath))      // 判断该path是不是一个目录
            cout << filePath << " is a directory\n";

        else
            cout << filePath << " exists, but is not a regular file or directory\n";
    }
    else
        cout << filePath << " does not exist\n";

    return 0;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016年10月08日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档