Link Error with tinyxml2

Link Error with tinyxml2
0.0 0


Started to get things going and I am looking to port in some of my code from another project. I have the following in the a function:

const char* name = _element->Name();

Where _element is a tinyxml2::XMLElement* _element

With this line I get the following link error:

error LNK2019: unresolved external symbol "public: char const * __thiscall tinyxml2::StrPair::GetStr(void)" (?GetStrStrPair@tinyxml2@QAEPBDXZ) referenced in function “public: char const * __thiscall tinyxml2::XMLNode::Value(void)const” (?Value@XMLNode@tinyxml2@QBEPBDXZ)@

As you can see this is coming from within tinyxml2. When I do a rebuild I see tinyxml2 actually building and can find the function in the code base.

Has anyone seen this error or know how to fix it (the libs are in the input for the library properties of the project).

If tinyxml2 is not to be used then is there an alternate xml reader?



I have the same problem since I upgrade to the last version of cocos2d-x (2.1.2) and libxml2 has been replaced by tinyxml

error LNK2019: unresolved external symbol “public: virtual thiscall tinyxml2::XMLDocument::~XMLDocument"
error LNK2019: unresolved external symbol "public: enum tinyxml2::XMLError
thiscall tinyxml2::XMLDocument::Parse(char const *,unsigned int)”
error LNK2019: unresolved external symbol “public: *thiscall tinyxml2::XMLDocument::XMLDocument"
error LNK2019: unresolved external symbol "public: char const **thiscall tinyxml2::StrPair::GetStr(void)” (?GetStr@StrPair@tinyxml2@@QAEPBDXZ)

And only when trying to compile on VS2010 for the win32 version.
No errors with eclipse for the android version.

If anyone has a solution, that would be great :slight_smile:




Oh, tinyxml is not exported on windows.
You should add CC_DLL in declaration as other classes.



Could you please explain how to use tinyxml2 in windows? I tried to add CC_DLL to class declaration which uses tinyxml, but I still got linkage errors.



Here is an example of what I am doing how it helps (please excuse the response layout not good at getting the layout right). One thing that I need to double check is the release of memory. Also when you do this you need to add the CC_DLL in your class declaration.


std::string _engineSetup = cocos2d::CCFileUtils::sharedFileUtils()>fullPathForFilename;
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument;
unsigned long nSize;
const char* pXmlBuffer = cocos2d::CCFileUtils::sharedFileUtils
>getFileData, “rb”, &nSize);
if {
CCLOG ("---------------- can not read xml file %d", nSize);
tinyxml2::XMLElement* element = xmlDoc~~>FirstChildElement( “ROOTELEMENT” );
CCAssert(element != NULL, “Cannot find ROOTELEMENT root Node”);

I have chosen not to use the tinyxml2 that is provided and just included my own in my project. I already have too many classes and am not about to change them. Overall it works fine and I am happy with the end result.