Public Group

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

## Recommended Posts

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 on other sites

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 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 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 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.
http://sourceforge.net/projects/tinyxml/

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 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.
http://sourceforge.n...ojects/tinyxml/

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 on other sites
Try defining TIXML_USE_STL globally for the entire project. My guess would be that the TinyXml source is compiled without this flag.

##### 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 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.

1. 1
2. 2
JoeJ
20
3. 3
4. 4
frob
12
5. 5

• 13
• 19
• 13
• 20
• 13
• ### Forum Statistics

• Total Topics
632194
• Total Posts
3004692

×