整站网站优化运营,手机兼职任务,广告页面设计图片,北京网站建设 知乎boost的filestem库
C在17版本的标准库中引入了一个filesystem库#xff0c;用来处理文件路径#xff0c;以及文件访问。很多编译器对filesystem库的支持还不是很好。为了解决这个问题#xff0c;可以临时使用boost::filesystem来替代。其实C17标准中的filesystem库就是从bo…boost的filestem库
C在17版本的标准库中引入了一个filesystem库用来处理文件路径以及文件访问。很多编译器对filesystem库的支持还不是很好。为了解决这个问题可以临时使用boost::filesystem来替代。其实C17标准中的filesystem库就是从boost::filesystem演进而来的使用boost::filesystem有助于以后平滑演进到C17的filesystem库。boost当前最新的版本是1.74.0是一大堆库的集合fiesystem只是其中的一个库。
boost上手文档
Boost Getting StartedBoostGetting Started on Unix Variants
boost::filestem入门教程
filesystem tutorial
在MAC上安装boost库文件 使用命令 brew install boost 在clion中对其进行配置 在CMakeLists.txt中对于boost部分进行配置find_package(Boost 1.74.0 REQUIRED COMPONENTS filesystem)cmake对boost有很好的支持上面的指令翻译如下1find_package(Boost 1.69.0 查找系统的boost, 目标版本是1.74.02REQUIRED COMPONENTS filesystem) COMPONENTS用来限定boost的filesystem模块REQUIRED表明必须找到指定的模块否则会出错上面的find_package命令如果找到boost::filesystem会在cmake中设置一些变量比如Boost_LIBRARIES、Boost_INCLUDE_DIRS需要在编译目标上使用这些变量。
其余的配置选项参考如下
cmake_minimum_required(VERSION 3.16)
project(KeyManager)set(CMAKE_CXX_STANDARD 11)find_package(Boost 1.74.0 REQUIRED COMPONENTS filesystem)
include_directories(${Boost_INCLUDE_DIRS})add_executable(KeyManager include/sdf/sdf.h include/sdf/SqliteManager.hsrc/SqliteManager.cppsrc/test.cpp include/sdf/KMException.h src/KMException.cpp include/sdf/logging.h src/logging.cpp src/KeyManager.cpp)
最为核心的是find_package和include_directories
具体使用
#include iostream
#include boost/version.hppusing namespace std;int main() {cout Hello, World! endl;cout Boost版本 BOOST_VERSION endl;return 0;
}
参考链接
boost的filesystem库C: Mac上安装Boost库并使用CLion开发