Menu

Getting started with TinyXML

Anonymous
2004-04-25
2004-04-26
  • Anonymous

    Anonymous - 2004-04-25

    If anyone can help a dumbass like myself, I would be most grateful. I'm a bit of a C++ newbie, so my code may not be very nice. Anyway, I've been trying to use TinyXML in a project I'm working on and just can't seem to get anywhere with it. The test program compiles and runs fine, so it must be me. I'm trying to figure out the minimum I need to get started.

    As I get the same errors regardless, I thought I'd give you a file with the least amount that give me errors, if you see what i mean.

    test.cc

    #include "tinyxml.h"
    #ifdef TIXML_USE_STL
      #include <iostream>
      #include <sstream>
      using namespace std;
    #else
            #include <stdio.h>
    #endif

    int main()
    {
      TiXmlDocument doc( "demotest.xml" );
      bool loadOkay = doc.LoadFile();
     
    }

    this is in a directory that only contains...
    $ ls test
    demotest.xml
    tinystr.cpp
    tinyxml.cpp
    tinyxmlerror.cpp
    test.cc
    tinystr.h
    tinyxml.h
    tinyxmlparser.cpp

    and if I run the following in that directory..
    g++ -DTIXML_USESTL -o test test

    I get the following error:
    /tmp/ccDQPcxN.o(.text+0x20): In function `main':
    undefined reference to `TiXmlDocument::TiXmlDocument[in-charge](char const*)'
    /tmp/ccDQPcxN.o(.text+0x2b): In function `main':
    undefined reference to `TiXmlDocument::LoadFile()'
    /tmp/ccDQPcxN.o(.gnu.linkonce.t._ZN13TiXmlDocumentD1Ev+0xb): In function `TiXmlDocument::~TiXmlDocument [in-charge]()':
    undefined reference to `vtable for TiXmlDocument'
    /tmp/ccDQPcxN.o(.gnu.linkonce.t._ZN13TiXmlDocumentD1Ev+0x24): In function `TiXmlDocument::~TiXmlDocument [in-charge]()':
    undefined reference to `TiXmlNode::~TiXmlNode [not-in-charge]()'
    collect2: ld returned 1 exit status

    I've been banging my head against this for some time and can't find anything to help me.

    Anyone got any ideas?

    Thanks

    Joe

     
    • Yves Berquin

      Yves Berquin - 2004-04-26

      I have no idea what system you run this on, but it seems to me it's only a linkage problem. Your source code compiled right, but the linker was not able to find the tinyxml code itself.
      You need to build tinyxml in a library and add it to your compile command, or generate a makefile and use a make to build your program.

       
    • Anonymous

      Anonymous - 2004-04-26

      Thanks, yes. I am not too familiar with compiling anything more complicated than a hello world app and thought g++ would Just Do It.

      Thanks for your help

       

Log in to post a comment.