0

I'm trying to build a solution in Visual Studio 2017. And I get these errors:

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 ==========

I have a feeling they can be solved by linking, but I am not sure what to link (the precise folder).

So far, I have built the yaml-cpp as described on github. Also, I have added the ..\yaml-cpp\include folder in the Additional Include Directories from Configuration Properties >> C/C++ >> General and tried to include in the Additional Library Directories (Linker) various folders, unsuccessfully.

Never used YAML before. And I don't link stuff often.

10
  • You do not link against a folder, but against a library file. Additional Library Directories only tells Visual Studio where to look for the libraries you want to link against. You need to add the library created by compiling yaml-cpp to the linker input. Commented Nov 20, 2017 at 11:07
  • @flyx, please be more precise. Commented Nov 20, 2017 at 11:21
  • 1
    If I knew Visual Studio, I would write an answer instead of just commenting. Commented Nov 20, 2017 at 12:59
  • I have a feeling they can be solved by linking, but I am not sure what to link - You need to link with .lib file. Find this file in the yaml-cpp tree (the file is created during building yaml-cpp project). Then follow regular steps for linking something in Visual Studio. Commented Nov 21, 2017 at 8:29
  • 1
    You need to add libyaml-cppmd.lib to the linker Input and the containing directory to the Additional Library Directories. Commented Nov 24, 2017 at 9:44

1 Answer 1

2

I was getting the unresolved external symbols errors because I was including #include <yaml-cpp/node/node.h>, which is what Resharper recommended me(and it's is correct 99.9% of the time). In this case it's a wrong header and what I should have been including is: #include <yaml-cpp/yaml.h>.

I fixed my includes in my files and it built successfully.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.