title: Using TinyXML ( linking libraries ? in c++ )
body: <p>+Hi...
  i am a newbie ... and i don't know how to include external libraries in c++.
  This is sooo hard.</p>
  
  <p>I want to use TinyXML.
  so i made this :</p>
  
  <p>example2.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "tinyxml.h"
  
  
  void write_app_settings_doc( )  
  {  
      TiXmlDocument doc;  
      TiXmlElement* msg;
      TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );  
      doc.LinkEndChild( decl );  
  
      TiXmlElement * root = new TiXmlElement( "MyApp" );  
      doc.LinkEndChild( root );  
  
      TiXmlComment * comment = new TiXmlComment();
      comment-&gt;SetValue(" Settings for MyApp " );  
      root-&gt;LinkEndChild( comment );  
  
      TiXmlElement * msgs = new TiXmlElement( "Messages" );  
      root-&gt;LinkEndChild( msgs );  
  
      msg = new TiXmlElement( "Welcome" );  
      msg-&gt;LinkEndChild( new TiXmlText( "Welcome to MyApp" ));  
      msgs-&gt;LinkEndChild( msg );  
  
      msg = new TiXmlElement( "Farewell" );  
      msg-&gt;LinkEndChild( new TiXmlText( "Thank you for using MyApp" ));  
      msgs-&gt;LinkEndChild( msg );  
  
      TiXmlElement * windows = new TiXmlElement( "Windows" );  
      root-&gt;LinkEndChild( windows );  
  
      TiXmlElement * window;
      window = new TiXmlElement( "Window" );  
      windows-&gt;LinkEndChild( window );  
      window-&gt;SetAttribute("name", "MainFrame");
      window-&gt;SetAttribute("x", 5);
      window-&gt;SetAttribute("y", 15);
      window-&gt;SetAttribute("w", 400);
      window-&gt;SetAttribute("h", 250);
  
      TiXmlElement * cxn = new TiXmlElement( "Connection" );  
      root-&gt;LinkEndChild( cxn );  
      cxn-&gt;SetAttribute("ip", "192.168.0.1");
      cxn-&gt;SetDoubleAttribute("timeout", 123.456); // floating point attrib
  
      doc.SaveFile( "appsettings.xml" );  
  } 
  
  
  int main()
  {
      write_app_settings_doc( );
    return 0;
  }
  </code></pre>
  
  <p>just an example file.
  So ..when i compile this with :</p>
  
  <blockquote>
    <p>g++ example2.cpp</p>
  </blockquote>
  
  <p>i get following error message:</p>
  
  <pre><code>/tmp/cc6npUsW.o: In function `write_app_settings_doc()':
  example2.cpp:(.text+0x13): undefined reference to `TiXmlDocument::TiXmlDocument()'
  example2.cpp:(.text+0x43): undefined reference to `TiXmlDeclaration::TiXmlDeclaration(char const*, char const*, char const*)'
  example2.cpp:(.text+0x58): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x8f): undefined reference to `TiXmlElement::TiXmlElement(char const*)'
  example2.cpp:(.text+0xa4): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x112): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x132): undefined reference to `TiXmlElement::TiXmlElement(char const*)'
  example2.cpp:(.text+0x147): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x17e): undefined reference to `TiXmlElement::TiXmlElement(char const*)'
  example2.cpp:(.text+0x1cb): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x1f4): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x214): undefined reference to `TiXmlElement::TiXmlElement(char const*)'
  example2.cpp:(.text+0x261): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x28a): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x2aa): undefined reference to `TiXmlElement::TiXmlElement(char const*)'
  example2.cpp:(.text+0x2bf): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x2f6): undefined reference to `TiXmlElement::TiXmlElement(char const*)'
  example2.cpp:(.text+0x30b): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x33d): undefined reference to `TiXmlElement::SetAttribute(char const*, char const*)'
  example2.cpp:(.text+0x358): undefined reference to `TiXmlElement::SetAttribute(char const*, int)'
  example2.cpp:(.text+0x373): undefined reference to `TiXmlElement::SetAttribute(char const*, int)'
  example2.cpp:(.text+0x38e): undefined reference to `TiXmlElement::SetAttribute(char const*, int)'
  example2.cpp:(.text+0x3a9): undefined reference to `TiXmlElement::SetAttribute(char const*, int)'
  example2.cpp:(.text+0x3c9): undefined reference to `TiXmlElement::TiXmlElement(char const*)'
  example2.cpp:(.text+0x3de): undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
  example2.cpp:(.text+0x40d): undefined reference to `TiXmlElement::SetAttribute(char const*, char const*)'
  example2.cpp:(.text+0x42a): undefined reference to `TiXmlElement::SetDoubleAttribute(char const*, double)'
  example2.cpp:(.text+0x43d): undefined reference to `TiXmlDocument::SaveFile(char const*) const'
  /tmp/cc6npUsW.o: In function `TiXmlString::operator=(char const*)':
  example2.cpp:(.text._ZN11TiXmlStringaSEPKc[TiXmlString::operator=(char const*)]+0x23): undefined reference to `TiXmlString::assign(char const*, unsigned int)'
  /tmp/cc6npUsW.o: In function `TiXmlString::quit()':
  example2.cpp:(.text._ZN11TiXmlString4quitEv[TiXmlString::quit()]+0xc): undefined reference to `TiXmlString::nullrep_'
  /tmp/cc6npUsW.o: In function `TiXmlComment::TiXmlComment()':
  example2.cpp:(.text._ZN12TiXmlCommentC1Ev[TiXmlComment::TiXmlComment()]+0x15): undefined reference to `TiXmlNode::TiXmlNode(TiXmlNode::NodeType)'
  example2.cpp:(.text._ZN12TiXmlCommentC1Ev[TiXmlComment::TiXmlComment()]+0x1e): undefined reference to `vtable for TiXmlComment'
  /tmp/cc6npUsW.o: In function `TiXmlText::TiXmlText(char const*)':
  example2.cpp:(.text._ZN9TiXmlTextC1EPKc[TiXmlText::TiXmlText(char const*)]+0x17): undefined reference to `TiXmlNode::TiXmlNode(TiXmlNode::NodeType)'
  example2.cpp:(.text._ZN9TiXmlTextC1EPKc[TiXmlText::TiXmlText(char const*)]+0x20): undefined reference to `vtable for TiXmlText'
  example2.cpp:(.text._ZN9TiXmlTextC1EPKc[TiXmlText::TiXmlText(char const*)]+0x4f): undefined reference to `TiXmlNode::~TiXmlNode()'
  /tmp/cc6npUsW.o: In function `TiXmlDocument::~TiXmlDocument()':
  example2.cpp:(.text._ZN13TiXmlDocumentD1Ev[TiXmlDocument::~TiXmlDocument()]+0xb): undefined reference to `vtable for TiXmlDocument'
  example2.cpp:(.text._ZN13TiXmlDocumentD1Ev[TiXmlDocument::~TiXmlDocument()]+0x24): undefined reference to `TiXmlNode::~TiXmlNode()'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I am mostly a java developer and i have a lot of problems in c++ to use external libraries.
  I dont know when to link . when to include. when i have to make -I/myincludepath/</p>
  
  <p>these files are in the same folder :</p>
  
  <blockquote>
    <p>example.cpp tinyxml.h tinyxml.cpp
    tinystr.h tinystr.cpp</p>
  </blockquote>
  
  <p>Can somebody help me ?</p>