Answer the question
In order to leave comments, you need to log in
Why does TinyXML2 give an error when trying to build?
I am using TinyXML2 to parse game maps from xml. (also using SFML)
Here is the 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.
Answer the question
In order to leave comments, you need to log in
The error is that the library with definitions TiXmlDocument::LoadFile
of other symbols is not passed to the linker during assembly. It is necessary in CMake, for example, to add link_libraries or target_link_libraries indicating TinyXML2, just like you did with SFML.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question