How to install and use YAML-Cpp

2019-07-14 19:54发布

问题:

I want to learn YAML (and use it with C++) but i'm stuck trying to setup YAML-Cpp. Let me explain what i've done so far.

  • I downloaded the source code (version 0.5.1)
  • Installed Cmake (for Windows)
  • Installed the Boost libraries (precompiled for Visual Studio 2010)

EDIT:

  • Built the solution and the INSTALL project
  • Then i got two folders on my C drive: include and lib
  • Then i moved it to another folder on my D drive (maybe it's relevant)

For testing, i created a project in V Express and tried to compile this:

#include "yaml-cpp/yaml.h"

int main()
{
   YAML::Emitter out;
   out << "Hello, World!";

   std::cout << "Here's the output YAML:\n" << out.c_str();
   return 0;
}

The new result:

d:\development\yamlcpp 0.51\include\yaml-cpp\node\ptr.h(10): fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp': No such file or directory

Can somebody please tell me what is the right way to build and configure this library?

回答1:

It looks like you're not including the proper directory. In Visual Studio, there's an option for the "include directories" - make sure that the include directory for yaml-cpp is listed there.



回答2:

marlon, you need to download boost-cpp (http://sourceforge.net/projects/boost/files/boost/1.58.0/), compile it and ensure to "include directory" in Visual Studio.