Windows下Boot的编译和使用
2016-10-08 14:56
309 查看
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的入门程序:
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的入门程序:
#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; }
相关文章推荐
- windows下使用makefile编译C语言.doc
- 如何在Windows下编译sqlite3,生成动态链接库并使用(New_070929)
- Windows下使用VIM,搭建Mainframe开发环境(二)---编译VIM
- Windows下使用VIM&Cygwin,搭建Mainframe开发环境(六)---用awk/sed合并PLI/Cobol编译结果
- 在Windows下编译sqlite3生成动态链接库并使用
- windows下编译和使用libpq
- Windows平台上使用VC6编译安装STLport
- 在Windows上使用VC编译并安装ACE
- Windows环境下log4cxx的编译及使用
- Windows 系统下使用 MinGW + MSYS + GCC 编译 FFMPEG
- 使用mingw和msys在windows上编译bdb
- 在Windows下使用汇编方式编译OpenSSL方法
- 用windows下编译过的eAccelerator for PHP 5.1.6实现php加速的使用方法
- 使用nmake在windows平台下编译xapian
- Windows环境下log4cxx的编译及使用
- 在Windows下编译sqlite3生成动态链接库并使用之
- cscope在windows下使用mingw编译的方法
- 用windows下编译过的eAccelerator for PHP 5.1.6实现php加速的使用方法
- 【原】Boost下载安装编译配置使用指南(含Windows、Linux以及ARM Linux)
- 在Windows中使用Cygwin环境下的gcc编译器编译【电脑教程网】Informix ESQ/C程序