Skip to content

"unresolved external symbol" error when using yaml-cpp as a static library in Visual Studio 2013 #332

@ghost

Description

I compiled yaml-cpp as a static library using Visual Studio Community 2013 and added the library to my project. This code works fine:

#include <yaml-cpp/yaml.h>
...

YAML::Node node = YAML::Load("{name: Brewers, city: Milwaukee}");
std::cout << node.size();

However, this code causes an error:

#include <yaml-cpp/yaml.h>
...

YAML::Node node = YAML::Load("{name: Brewers, city: Milwaukee}");
std::cout << node["name"];

Output is below:

1>------ Build started: Project: myapp, Configuration: Debug Win32 ------
1>  Application.cpp
1>Application.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>D:\code\cpp\myapp\Debug\myapp.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

GCC compiles both codes successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions