yaml-cpp未解析的外部符号错误

时间:2017-11-20 10:25:08

标签: c++ visual-studio yaml linker-errors

我正在尝试在Visual Studio 2017中构建解决方案。我收到了这些错误:

1>------ Build started: Project: UA_Parser, Configuration: Release x64 ------
1>UaParserTest.cpp
1>UaParser.obj : error LNK2001: unresolved external symbol "class YAML::Node __cdecl YAML::LoadFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?LoadFile@YAML@@YA?AVNode@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl YAML::InvalidNode::~InvalidNode(void)" (??1InvalidNode@YAML@@UEAA@XZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl YAML::Exception::~Exception(void)" (??1Exception@YAML@@UEAA@XZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl YAML::RepresentationException::~RepresentationException(void)" (??1RepresentationException@YAML@@UEAA@XZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl YAML::BadConversion::~BadConversion(void)" (??1BadConversion@YAML@@UEAA@XZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl YAML::BadSubscript::~BadSubscript(void)" (??1BadSubscript@YAML@@UEAA@XZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: class YAML::detail::node & __cdecl YAML::detail::memory::create_node(void)" (?create_node@memory@detail@YAML@@QEAAAEAVnode@23@XZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "private: void __cdecl YAML::detail::node_data::convert_to_map(class std::shared_ptr<class YAML::detail::memory_holder>)" (?convert_to_map@node_data@detail@YAML@@AEAAXV?$shared_ptr@Vmemory_holder@detail@YAML@@@std@@@Z)
1>UaParser.obj : error LNK2001: unresolved external symbol "private: void __cdecl YAML::detail::node_data::insert_map_pair(class YAML::detail::node &,class YAML::detail::node &)" (?insert_map_pair@node_data@detail@YAML@@AEAAXAEAVnode@23@0@Z)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: class YAML::detail::node_iterator_base<class YAML::detail::node> __cdecl YAML::detail::node_data::end(void)" (?end@node_data@detail@YAML@@QEAA?AV?$node_iterator_base@Vnode@detail@YAML@@@23@XZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: class YAML::detail::node_iterator_base<class YAML::detail::node> __cdecl YAML::detail::node_data::begin(void)" (?begin@node_data@detail@YAML@@QEAA?AV?$node_iterator_base@Vnode@detail@YAML@@@23@XZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: void __cdecl YAML::detail::node_data::set_scalar(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?set_scalar@node_data@detail@YAML@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: void __cdecl YAML::detail::node_data::set_null(void)" (?set_null@node_data@detail@YAML@@QEAAXXZ)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: void __cdecl YAML::detail::node_data::mark_defined(void)" (?mark_defined@node_data@detail@YAML@@QEAAXXZ)
1>UaParser.obj : error LNK2001: 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" (?empty_scalar@node_data@detail@YAML@@2V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
1>UaParser.obj : error LNK2001: unresolved external symbol "public: void __cdecl YAML::detail::memory_holder::merge(class YAML::detail::memory_holder &)" (?merge@memory_holder@detail@YAML@@QEAAXAEAV123@@Z)
1>C:\bmetric\C++ Projects\UA_Parser\x64\Release\UA_Parser.exe : fatal error LNK1120: 16 unresolved externals
1>Done building project "UA_Parser.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我有一种感觉,他们可以通过链接解决,但我不知道链接到什么(精确的文件夹)。

到目前为止,我已经构建了github上描述的yaml-cpp。另外,我在..\yaml-cpp\include Additional Include Directories中添加了Configuration Properties >> C/C++ >> General文件夹,并尝试在Additional Library Directories(链接器)中包含各种文件夹,但未成功。

之前从未使用过YAML。而且我不经常联系。

1 个答案:

答案 0 :(得分:0)

我收到了未解决的外部符号错误,因为我包含了 #include <yaml-cpp/node/node.h>,这是 Resharper 推荐我的(并且在 99.9% 的情况下是正确的)。在这种情况下,这是一个错误的标题,我应该包含的是:#include <yaml-cpp/yaml.h>

我修复了我的文件中的包含并成功构建。