TinyXML2 启动失败

发布于 2025-01-09 02:06:09 字数 2689 浏览 0 评论 0原文

我正在使用 TinyXML2 来解析 XML,当我尝试运行时,出现以下错误:

FAILED: project_flag 
: && /Library/Developer/CommandLineTools/usr/bin/c++ -std=c++11 -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/project_flag.dir/main.cpp.o CMakeFiles/project_flag.dir/lib/TinyXML2/include/tinyxml2.cpp.o -o project_flag  -Wl,-rpath,/usr/local/lib  /usr/local/lib/libsfml-graphics.2.5.1.dylib  /usr/local/lib/libsfml-audio.2.5.1.dylib  /usr/local/lib/libsfml-network.2.5.1.dylib  /usr/local/lib/libsfml-window.2.5.1.dylib  /usr/local/lib/libsfml-system.2.5.1.dylib && :
Undefined symbols for architecture x86_64:
  "TiXmlString::nullrep_", referenced from:
      TiXmlString::quit() in main.cpp.o
  "TiXmlDocument::LoadFile(TiXmlEncoding)", referenced from:
      Level::LoadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main.cpp.o
      AnimationManager::loadFromXML(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, sf::Texture&) in main.cpp.o
  "TiXmlDocument::TiXmlDocument(char const*)", referenced from:
      Level::LoadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main.cpp.o
      AnimationManager::loadFromXML(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, sf::Texture&) in main.cpp.o
  "TiXmlNode::~TiXmlNode()", referenced from:
      TiXmlDocument::~TiXmlDocument() in main.cpp.o
  "TiXmlElement::Attribute(char const*) const", referenced from:
      Level::LoadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main.cpp.o
      AnimationManager::loadFromXML(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, sf::Texture&) in main.cpp.o
  "TiXmlNode::FirstChildElement(char const*) const", referenced from:
      TiXmlNode::FirstChildElement(char const*) in main.cpp.o
  "TiXmlNode::NextSiblingElement(char const*) const", referenced from:
      TiXmlNode::NextSiblingElement(char const*) in main.cpp.o
  "vtable for TiXmlDocument", referenced from:
      TiXmlDocument::~TiXmlDocument() in main.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

如何修复此错误?

I am using TinyXML2 to parse XML and when I try to run I get the following error:

FAILED: project_flag 
: && /Library/Developer/CommandLineTools/usr/bin/c++ -std=c++11 -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/project_flag.dir/main.cpp.o CMakeFiles/project_flag.dir/lib/TinyXML2/include/tinyxml2.cpp.o -o project_flag  -Wl,-rpath,/usr/local/lib  /usr/local/lib/libsfml-graphics.2.5.1.dylib  /usr/local/lib/libsfml-audio.2.5.1.dylib  /usr/local/lib/libsfml-network.2.5.1.dylib  /usr/local/lib/libsfml-window.2.5.1.dylib  /usr/local/lib/libsfml-system.2.5.1.dylib && :
Undefined symbols for architecture x86_64:
  "TiXmlString::nullrep_", referenced from:
      TiXmlString::quit() in main.cpp.o
  "TiXmlDocument::LoadFile(TiXmlEncoding)", referenced from:
      Level::LoadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main.cpp.o
      AnimationManager::loadFromXML(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, sf::Texture&) in main.cpp.o
  "TiXmlDocument::TiXmlDocument(char const*)", referenced from:
      Level::LoadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main.cpp.o
      AnimationManager::loadFromXML(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, sf::Texture&) in main.cpp.o
  "TiXmlNode::~TiXmlNode()", referenced from:
      TiXmlDocument::~TiXmlDocument() in main.cpp.o
  "TiXmlElement::Attribute(char const*) const", referenced from:
      Level::LoadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main.cpp.o
      AnimationManager::loadFromXML(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, sf::Texture&) in main.cpp.o
  "TiXmlNode::FirstChildElement(char const*) const", referenced from:
      TiXmlNode::FirstChildElement(char const*) in main.cpp.o
  "TiXmlNode::NextSiblingElement(char const*) const", referenced from:
      TiXmlNode::NextSiblingElement(char const*) in main.cpp.o
  "vtable for TiXmlDocument", referenced from:
      TiXmlDocument::~TiXmlDocument() in main.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

How can I fix this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南巷近海 2025-01-16 02:06:09

我在自己的 tinyxml2 头文件/源文件副本中进行了快速搜索,发现 TiXmlString::nullrep_ 不存在。然后我在互联网上搜索了相同的代码:

TinyXML / Bugs / #68 Fixinitializer TiXmlString::nullrep_

因此,您尝试使用的代码来自较旧的 TinyXML 库,而不是后者 <代码>TinyXML-2 库。您很可能必须重构您的代码。

I did a quick search in my own copies of tinyxml2 header / source files and TiXmlString::nullrep_ does not exist. I then did a search for the same code on the internet:

TinyXML / Bugs / #68 Fix initialiser of TiXmlString::nullrep_

Thus the code you are trying to use is from the older TinyXML library and not the latter TinyXML-2 library. You will most likely have to refactor your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文