Thread: problem with loading tinyXML

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    38

    Question problem with loading tinyXML

    Sorry, i'm quite new to C++. I been searching about C++ XML parser for half the day now, i read alot of stuff about how to use it. However i have yet to find a tutorial on "How to load the tinyXML header?".

    Could someone so kindly tell me how I could load it?

    I tired downloading it and stuffing it next to the source code of my project then i used #include "tinyxml.h" to attempt to load it however it gave me a linking error. So i guess i'm stuck wondering if i placed the tinyxml file correctly.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

    Unhappy

    You also need to *link* the library. Just including the header isn't enough. How you link in the library will depend on your development environment.

    You also might take a few minutes to read the file entitled readme.txt (natch) in the download.

    ANOTHER EDIT: OK, the readme is the same as this page, so never mind. However, the docs state:

    To Use in an Application:

    Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, tinystr.cpp, and tinystr.h to your project or make file. That's it! It should compile on any reasonably compliant C++ system. You do not need to enable exceptions or RTTI for TinyXML.
    so you might consider telling us how you're building your application and what are the exact errors.
    Last edited by rags_to_riches; 10-04-2011 at 05:10 PM.

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    38
    I'm using the "xmlTest" Dev-C++ Project File that i unpacked from the zip. I just unpacked it and ran it and it gave me a huge error list.

    [Linker error] undefined reference to `TiXmlDocument::TiXmlDocument(char const*)'
    [Linker error] undefined reference to `TiXmlDocument::Parse(char const*, TiXmlParsingData*, TiXmlEncoding)'
    [Linker error] undefined reference to `TiXmlDocument::SaveFile() const'
    [Linker error] undefined reference to `TiXmlDocument::TiXmlDocument(char const*)'
    [Linker error] undefined reference to `TiXmlDocument::LoadFile(TiXmlEncoding)'
    [Linker error] undefined reference to `TiXmlDocument::Print(_iobuf*, int) const'
    [Linker error] undefined reference to `TiXmlDocument::Accept(TiXmlVisitor*) const'
    [Linker error] undefined reference to `TiXmlElement::SetAttribute(char const*, int)'
    ...

  4. #4
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by airesore View Post
    I'm using the "xmlTest" Dev-C++ Project File that i unpacked from the zip. I just unpacked it and ran it and it gave me a huge error list.
    You need to add all the files to the project, not just include the header file.

    Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, tinystr.cpp, and tinystr.h to your project alongside your own files, then include tinyxml.h in the places where you use it, and press compile.

    Also, you're using an old and deprecated IDE, you should move to code::blocks instead.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    38
    Still gives me error, but less this time. However I still seem to be missing something.

    Code:
    #include <cstdlib>
    #include <iostream>
    # include "tinyxml.h"
    
    using namespace std;
    
    using std::cout;
    using std::string;
    
    
    int main() {
           TiXmlDocument doc("duck.xml");
        system("PAUSE");
    }
    Error message:
    problem with loading tinyXML-tinytest-error-png

    ProjectFolder:
    problem with loading tinyXML-tinytest-png

    Please help me thanks

    EDIT:Nevermind, downloaded some guy's package who had tinyXML loaded already and will be modiftying his code to suit my needs.
    Last edited by airesore; 10-05-2011 at 11:01 AM.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You must link with tinyxml.lib or tinyxml_stl.lib depending on which version you are using. TinyXML is very simple to use but does not support more advanced features like serialization to / from XML, etc. I use it frequently both at home and work and it is suitable for most tasks involving XML. Xerces XML is another good XML library but it is far more robust, a bit harder to wrap your head around, and I do not think it is free.

  7. #7
    Registered User
    Join Date
    Sep 2011
    Posts
    38
    I can't seem to link the library. There's isn't a A file that I could use to link it with. There is however a visual C++ lib file, but i''m using bloodshed's Dev C++.

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Is there a reason you have to use that compiler? I do not think tinyXML has any MS dependent features in it so the library should work. The STL version may not as it depends on the version that MSVS uses but the non-STL version should work. If you do not care about the compiler of choice or do not have to be cross-platform then go get MSVS 2008 or MSVS 2010 express.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    There is also Visual Studio Develop Preview (11) which has code analysis built-in. Very handy feature that. Still, it is quite a big download, so I wouldn't force you to download it. IF you're going VS, that is.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'm sure you could email the author of tinyXML and explain your problem. The library is quite good and a godsend for super simple XML support (read: simple parsing and creation support) which is normally what you need. I've used this library for almost 4 years so if you have any issues with it I can certainly try to assist.

    If memory serves me you can download the source and compile it yourself so the compiler should not matter if the source is portable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function loading problem
    By fighter92 in forum C++ Programming
    Replies: 6
    Last Post: 06-07-2008, 03:54 AM
  2. tinyxml & C++
    By bobthebullet990 in forum C++ Programming
    Replies: 3
    Last Post: 05-04-2006, 03:48 PM
  3. TinyXML - copy subtrees
    By pixsta in forum C++ Programming
    Replies: 1
    Last Post: 01-30-2006, 03:23 PM
  4. Loading Bitmap Problem
    By loopshot in forum Game Programming
    Replies: 1
    Last Post: 04-15-2005, 12:26 PM
  5. Problem with bitmap loading.
    By ZooTrigger1191 in forum Windows Programming
    Replies: 2
    Last Post: 02-20-2003, 02:41 PM

Tags for this Thread