c++ 开发中利用yaml-cpp读写yaml配置文件
1、yaml-cpp 是一个开源库,地址在 github 上,https://github.com/jbeder/yaml-cpp。
在ubuntu中可以输入git clone https://github.com/jbeder/yaml-cpp
获取yaml-cpp源码。
2、进入到yaml-cpp目录,新建一个build目录。
3、进入到build目录,输入cmake -D BUILD_SHARED_LIBS=ON …编译出动态库。
4、创建自己测试用的文件夹,将yaml-cpp目录下面的include 目录拷贝到测试目录下,将编译后的动态库也拷贝到测试目录下,同事目录下在编写三个文件,分别为CMakeLists.txt、config.yaml、main.cpp。
main.cpp内容如下:
#include <iostream>
#include "include/yaml-cpp/yaml.h"
using n