Having problems with yaml.cpp lib in c++
我在尝试在项目中使用yaml-cpp 0.3.0时遇到了困难
我下载了yaml,并使用VS 9 2008 WIN 64像http://code.google.com/p/yaml-cpp/所说的那样构建了它。于是,我得到了yaml-cpp.dll和yaml-cpp.lib
我在VS 2010 Express上有一个C项目,并且我正在尝试链接库:
我转到项目属性-c / c常规和附加的包含yaml-cpp头文件的目录。然后我转到链接器,然后将路径添加到我的lib目录,然后转到链接器,输入并添加了我的.lib文件,然后转到VC目录,并在Library目录和Reference目录中添加了我的lib目录的路径。
然后,我尝试构建以下简单代码:
1 2 3 4 5 6 | std::ifstream fin("test.yaml"); YAML::Parser parser(fin); YAML::Node doc; while(parser.GetNextDocument(doc)) { //do nothing yet } |
我遇到了几个链接问题,如下所示:
1 2 3 4 | error LNK2019: unresolved external symbol"public: __thiscall YAML::Node::Node(void)" (??0Node@YAML@@QAE@XZ) referenced in function"public: __thiscall Parser::Parser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Parser@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) error LNK2019: unresolved external symbol"public: __thiscall YAML::Parser::~Parser(void)" (??1Parser@YAML@@QAE@XZ) referenced in function"public: __thiscall Parser::Parser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Parser@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) |
有人可以帮助我吗?我在这里撞墙。
正如您所说的那样,您从YAML中获得了一个DLL,我假设您在使用VS2008构建时指定了
如果上述正确,则可能是VS2008与VS2010之间的差异导致了问题。例如,在这里看到这篇文章。若要快速查看是否是此原因,请在VS2010项目属性中将
另外,请确保您为同一CPU编译了两个项目-即都针对32位或针对64位。