What is the issue you have?
Linker error LNK2005:
unit-regression2.obj : error LNK2005: "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * sax_no_exception::error_string" (?error_string@sax_no_exception@@2PEAV?$basic_string@DU?$char_traits@D@std@@V?$allo
cator@D@2@@std@@EA) already defined in unit-disabled_exceptions.obj [build\json\test\json_unit.vcxproj]
build\json\test\Release\json_unit.exe : fatal error LNK1169: one or more multiply defined symbols found [build\json\test\json_unit.vcxproj]
Can you provide a small but working solution / fix?
Add a namespace in both files json\test\src\unit-disabled_exceptions.cpp and json\test\src\unit-regression2.cpp:
namespace
{
class sax_no_exception : public nlohmann::detail::json_sax_dom_parser<json>
{
...
};
std::string* sax_no_exception::error_string = nullptr;
} // namespace
What is the expected behavior?
No link error
And what is the actual behavior instead?
LNK2005 error
Which compiler and operating system are you using?
- Compiler: Visual Studio 2019 16.11.1 Professional
- Operating system: Windows 10 21H1
Which version of the library did you use?
What is the issue you have?
Linker error LNK2005:
Can you provide a small but working solution / fix?
Add a namespace in both files
json\test\src\unit-disabled_exceptions.cppandjson\test\src\unit-regression2.cpp:What is the expected behavior?
No link error
And what is the actual behavior instead?
LNK2005 error
Which compiler and operating system are you using?
Which version of the library did you use?
developbranchIf you experience a compilation error: can you compile and run the unit tests?