cd yaml-cpp-release-0.5.3 mkdir build cd build cmake .. make make install
#include <iostream> #include <fstream> #include <yaml-cpp/yaml.h> #include <time.h> int main(int argc, const char * argv[]) { // insert code here... YAML::Node config = YAML::LoadFile("config.yaml"); const std::string username = config["username"].as<std::string>(); const std::string password = config["password"].as<std::string>(); time_t ltime; time(<ime); config["lastLogin"] = ctime(<ime); std::ofstream fout("config.yaml"); fout << config; std::cout << "username: " << username <<" password " << password << std::endl; return 0; }
g++ main.cpp -I/usr/local/include -L/usr/local/lib -lyaml-cpp -o test ./test
"YAML::LoadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from: clang: error: linker command failed with exit code 1 (use -v to see invocation)
http://www.xuebuyuan.com/866409.html
https://github.com/jbeder/yaml-cpp/wiki/Tutorial
http://stackoverflow.com/questions/2202179/problem-using-yaml-cpp-on-os-x