3

I have a YAML file consisting of:

abc: 123

And I'm using the following code to load it:

YAML::Node base = YAML::Load("test.yaml");
std::cout << base["abc"].as<int>() << std::endl;

MSVC fails to link (caused by the second line), stating:

unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > YAML::detail::node_data::empty_scalar"

I don't know what I'm doing wrong, or if I just set it up wrong. It links and parses files fine, just doesn't let me use YAML::Node::operator[] without giving me an error.

Thoom1940
  • 31
  • 2

1 Answers1

0

You have to link with the yaml-cpp library.

Gustavo Muenz
  • 9,278
  • 7
  • 40
  • 42
  • I did link the library. Like I said, it will parse files file (which I will assume wouldn't work if I hadn't linked the library), I'm just having trouble accessing the data in the files after parsing them. – Thoom1940 May 15 '16 at 15:35
  • @Thoom Perhaps you should show the code which does work. – Alan Stokes May 15 '16 at 15:53
  • @AlanStokes If I remove the second line it works. I can also catch `YAML::ParserException`s being thrown to obtain error messages from an invalid YAML file. It's only when I access data from a file I've loaded (via `operator[]`) does my code no longer work. It's possible other functions are effected to, but I don't know much about the library. – Thoom1940 May 15 '16 at 15:57