Jump to content
  • Advertisement
Sign in to follow this  

TinyXML Linker errors help beginner please!

This topic is 2440 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

We never had proper linker learning in school and I have no idea about this stuff so sorry if I seem retarded.

I'm trying to implement TinyXML to my C++ project using Visual Studio.
This is what I have done so far:

Added following files to same directory as the other files of the project:
tinystr.cpp
tinystr.h
tinyxml.cpp
tinyxml.h
tinyxmlerror.cpp
tinyxmlparser.cpp

Added these include lines in the .h file of the class which uses tinyXML:
#define TIXML_USE_STL
#include <tinyxml.h>

using std::cout;
using std::string;

These are some of the linker errors I recieve:
Error 144 error LNK2019: unresolved external symbol "public: virtual __thiscall TiXmlNode::~TiXmlNode(void)" (??1TiXmlNode@@UAE@XZ) referenced in function __unwindfunclet$??0TiXmlText@@QAE@PBD@Z$0 cResourceManager.obj
Error 145 error LNK2019: unresolved external symbol "protected: __thiscall TiXmlNode::TiXmlNode(enum TiXmlNode::NodeType)" (??0TiXmlNode@@IAE@W4NodeType@0@@Z) referenced in function "public: __thiscall TiXmlText::TiXmlText(char const *)" (??0TiXmlText@@QAE@PBD@Z) cResourceManager.obj
Error 149 error LNK2001: unresolved external symbol "public: virtual bool __thiscall TiXmlText::Accept(class TiXmlVisitor *)const " (?Accept@TiXmlText@@UBE_NPAVTiXmlVisitor@@@Z) cResourceManager.obj


Where am I failing? Someone enlighten me please!

Share this post


Link to post
Share on other sites
Advertisement

We never had proper linker learning in school and I have no idea about this stuff so sorry if I seem retarded.

I'm trying to implement TinyXML to my C++ project using Visual Studio.
This is what I have done so far:

Added following files to same directory as the other files of the project:
tinystr.cpp
tinystr.h
tinyxml.cpp
tinyxml.h
tinyxmlerror.cpp
tinyxmlparser.cpp

Added these include lines in the .h file of the class which uses tinyXML:
#define TIXML_USE_STL
#include <tinyxml.h>

using std::cout;
using std::string;

These are some of the linker errors I recieve:
Error 144 error LNK2019: unresolved external symbol "public: virtual __thiscall TiXmlNode::~TiXmlNode(void)" (??1TiXmlNode@@UAE@XZ) referenced in function __unwindfunclet$??0TiXmlText@@QAE@PBD@Z$0 cResourceManager.obj
Error 145 error LNK2019: unresolved external symbol "protected: __thiscall TiXmlNode::TiXmlNode(enum TiXmlNode::NodeType)" (??0TiXmlNode@@IAE@W4NodeType@0@@Z) referenced in function "public: __thiscall TiXmlText::TiXmlText(char const *)" (??0TiXmlText@@QAE@PBD@Z) cResourceManager.obj
Error 149 error LNK2001: unresolved external symbol "public: virtual bool __thiscall TiXmlText::Accept(class TiXmlVisitor *)const " (?Accept@TiXmlText@@UBE_NPAVTiXmlVisitor@@@Z) cResourceManager.obj


Where am I failing? Someone enlighten me please!

In your linker settings you need to link against one of the tinyXML.lib files for it to find the symbols

Share this post


Link to post
Share on other sites
Okay, now I tried adding them to the project too instead of just put them in same folder and I get these errors instead.. any ideas?

Error 2 error LNK2001: unresolved external symbol "protected: virtual void __thiscall TiXmlText::StreamIn(class std::basic_istream<char,struct std::char_traits<char> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?StreamIn@TiXmlText@@MAEXPAV?$basic_istream@DU?$char_traits@D@std@@@std@@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z) cResourceManager.obj
Error 3 error LNK2001: unresolved external symbol "protected: virtual void __thiscall TiXmlDocument::StreamIn(class std::basic_istream<char,struct std::char_traits<char> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?StreamIn@TiXmlDocument@@MAEXPAV?$basic_istream@DU?$char_traits@D@std@@@std@@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z) cResourceManager.obj

Share this post


Link to post
Share on other sites

In your linker settings you need to link against one of the tinyXML.lib files for it to find the symbols


Ahh, yeah I've been searching the internet for the tinyXML.lib file but cannot find it. Dunno if Im supposed to make one myself then, and in that case.. how?

Share this post


Link to post
Share on other sites

[quote name='NightCreature83' timestamp='1316171274' post='4862392']
In your linker settings you need to link against one of the tinyXML.lib files for it to find the symbols


Ahh, yeah I've been searching the internet for the tinyXML.lib file but cannot find it. Dunno if Im supposed to make one myself then, and in that case.. how?
[/quote]

If you add all the .cpp and .h files from tinyxml to your project, you shouldn't need any .lib
It all works fine on my computer when I do that.

ps.
I downloaded tinyxml from here:
http://sourceforge.net/projects/tinyxml/
not the version at code.google.com

pps.
If you want a .lib file, you can create one by opening the file tinyxml.sln from the unzipped folder in visual studio and hit build from the menu.
Do this for both debug and release, and you should find the .lib files (One for debug and one for release) in some subfolders.
After that, you need to edit the project settings in your own project so that your project can find the tinyxml .h and .lib files.
I won't try to explain how to do that here since it shouldn't be necessary. Adding the .h and .cpp files directly to your project should work...

Share this post


Link to post
Share on other sites

[quote name='XiNouvA' timestamp='1316171485' post='4862395']
[quote name='NightCreature83' timestamp='1316171274' post='4862392']
In your linker settings you need to link against one of the tinyXML.lib files for it to find the symbols


Ahh, yeah I've been searching the internet for the tinyXML.lib file but cannot find it. Dunno if Im supposed to make one myself then, and in that case.. how?
[/quote]

If you add all the .cpp and .h files from tinyxml to your project, you shouldn't need any .lib
It all works fine on my computer when I do that.

ps.
I downloaded tinyxml from here:
http://sourceforge.n...ojects/tinyxml/
not the version at code.google.com

pps.
If you want a .lib file, you can create one by opening the file tinyxml.sln from the unzipped folder in visual studio and hit build from the menu.
Do this for both debug and release, and you should find the .lib files (One for debug and one for release) in some subfolders.
After that, you need to edit the project settings in your own project so that your project can find the tinyxml .h and .lib files.
I won't try to explain how to do that here since it shouldn't be necessary. Adding the .h and .cpp files directly to your project should work...
[/quote]

It is better to link against the lib file though as that won't polute your project with the xml reader when it doesn't need to know about it. I made some minor changes to my copy of tinyXML as well so you can read bool values with a function instead of having to read an int and convert it to a bool.

Share this post


Link to post
Share on other sites
I use Visual studio 2005 and it says it cannot open the tinyxml.sln because its of a newer version.

Wow.. thanks CableGuy, it finally compiled when I moved the #define TIXML_USE_STL to the main.cpp

Share this post


Link to post
Share on other sites

Wow.. thanks CableGuy, it finally compiled when I moved the #define TIXML_USE_STL to the main.cpp


Thats not the best place to put it, put it in the project settings instead:
Properties -> Configuration -> C/C++ -> Preprocessor ->Preprocessor Definitations

There may be more appropriate places to put it than that but main isn't one of them, it's semi by chance it works correctly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!