title: duplicate symbols for architecture x86_64 qt
body: <p>I started with Qt and now I have got this error:</p>
  
  <pre><code>duplicate symbol _t in:
      main.o
      handler.o
  duplicate symbol _mp in:
      main.o
      handler.o
  duplicate symbol _l in:
      main.o
      handler.o 
  duplicate symbol _ti in:
      main.o
      handler.o 
  ld: 4 
  duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>main.cpp:</p>
  
  <pre><code>#include "handler.h"
  
  int main(int argc, char **argv)
  {
      QFile *file = new QFile(":/xml/example.tmx");
  
      QXmlSimpleReader xmlReader;
      QXmlInputSource *source = new QXmlInputSource(file);
  
      Handler *handler = new Handler;
      xmlReader.setContentHandler(handler);
      xmlReader.setErrorHandler(handler);
  
      bool ok = xmlReader.parse(source);
      if (!ok)
          std::cout &lt;&lt; "Parsing failed." &lt;&lt; std::endl;
      else {
          QStringList names = handler-&gt;names();
          QStringList attributes = handler-&gt;attributes();
          QStringList attributeName = handler-&gt;attributeName();
          QList&lt;int&gt; indentations = handler-&gt;indentations();
          QList&lt;int&gt; anzahl = handler-&gt;anzahl();
          int items = names.count();
  
          int durchgang = 0;
          for (int i = 0; i &lt; items; ++i) {
              for (int j = 0; j &lt; indentations[i]; ++j){
                  std::cout &lt;&lt; " ";
              }
              std::cout &lt;&lt; names[i].toLocal8Bit().constData() &lt;&lt; " " ;
              //weitere attribute printen(so viele wie vorhanden
  
              for(int y = 0; y &lt; anzahl[i] ; y++){
                  std::cout &lt;&lt; attributeName[durchgang].toLocal8Bit().constData() &lt;&lt; " = "&lt;&lt; attributes[durchgang].toLocal8Bit().constData() &lt;&lt; "   ";
                  durchgang++;
              }
              std::cout &lt;&lt; std::endl;
          }
  
          imageloader il;
          QStringList sources;
          for(int x = 0; x &lt; mp.tilesets.length();x++){
              sources.append(mp.tilesets[x].source);
          }
          QList &lt;QImage&gt; images;
         images = il.Loadtilesets(mp.tilesets.length(),sources);
      }
      std::cout &lt;&lt; "Beendet"&lt;&lt;std::endl;
      return 0;
  }
  </code></pre>
  
  <p>handler.cpp:</p>
  
  <pre><code>#include "handler.h"
  
  /*!
      Reset the state of the handler to ensure that new documents are
      read correctly.
  
      We return true to indicate that parsing should continue.
  */
  
  bool Handler::startDocument()
  {
      elementName.clear();
      elementAttributes.clear();
      elementIndentation.clear();
      elementAnzahl.clear();
      elementAttributeName.clear();
      indentationLevel = 0;
  
      return true;
  }
  
  /*!
      Process each starting element in the XML document.
  
      Append the element name to the list of elements found; add its
      corresponding indentation level to the list of indentation levels.
  
      Increase the level of indentation by one column.
  
      We return true to indicate that parsing should continue.
  */
  
  bool Handler::startElement(const QString &amp;, const QString &amp;,
      const QString &amp; qName, const QXmlAttributes &amp; atts)
  {
      elementName.append(qName);
      int anzahl = 0;
  
      for(int index = 0; index &lt; atts.length();index++){
          int d = index;
          if(qName == "map"){//alle attribute von map
              if(atts.qName(index) == "width"){
                  mp.width = atts.value(index).toInt();
                  index ++;
              }
              if(atts.qName(index)== "height"){
                  mp.height = atts.value(index).toInt();
                  index++;
              }
          }
  
          if(qName == "tileset"){
          tileset t;
  
              if(atts.qName(index)=="firstgid"){
                  t.firstgid = atts.value(index).toInt();
                  index++;
              }
              if(atts.qName(index)=="name"){
                  t.name = atts.value(index);
                  index ++;
              }
              if(atts.qName(index)=="tilewidth"){
                  t.tilewidth = atts.value(index).toInt();
                  index++;
              }
              if(atts.qName(index)=="tileheight"){
                  t.tileheight = atts.value(index).toInt();
                  index++;
              }
              if(atts.qName(index)=="tilecount"){
                  t.tilecount = atts.value(index).toInt();
                  index++;
              }
              if(atts.qName(index)=="columns"){
                  t.columns = atts.value(index).toInt();
                  index++;
              }
          }
          if(qName == "image"){//!muss noch ein try catch block einbauen fals ein image nicht hinter einem tileset ist
              if(atts.qName(index) == "source"){
                  t.source = atts.qName(index);
                  mp.tilesets.append(t);
              }
          }
          if(qName =="layer"){
              if(atts.qName(index)=="name"){
                  l.name = atts.qName(index);
                  index++;
              }
              if(atts.qName(index)=="width"){
                  l.width = atts.qName(index).toInt();
                  index++;
              }
              if(atts.qName(index)=="height"){
                  l.height= atts.qName(index).toInt();
                  index++;
              }
          }
          if(qName == "data"){
              for(int x = 0; x&lt; l.height*l.width; x++){
                  if(atts.qName(index)=="gid"){
                      ti.gid = atts.value(index).toInt();
                      l.tiles.append(ti);
                      index++;
                  }
  
              }
              mp.layers.append(l);
          }
  
          index = d;//für das auslesen und couten
          elementAttributes.append(atts.value(index));
          elementAttributeName.append(atts.qName(index));
          anzahl = index+1;
      }
  
      elementAnzahl.append(anzahl);
  
      elementIndentation.append(indentationLevel);
      indentationLevel += 1;
  
      return true;
  }
  /*!
      Process each ending element in the XML document.
  
      Decrease the level of indentation by one column.
  
      We return true to indicate that parsing should continue.
  */
  
  bool Handler::endElement(const QString &amp;, const QString &amp;,
      const QString &amp;)
  {
      indentationLevel -= 1;
      return true;
  }
  
  /*!
      Report a fatal parsing error, and return false to indicate to the reader
      that parsing should stop.
  */
  
  bool Handler::fatalError (const QXmlParseException &amp; exception)
  {
      qWarning() &lt;&lt; QString("Fatal error on line %1, column %2: %3").arg(
          exception.lineNumber()).arg(exception.columnNumber()).arg(
          exception.message());
  
      return false;
  }
  
  /*!
      Return the list of element names found.
  */
  
  QStringList&amp; Handler::names ()
  {
      return elementName;
  }
  
  QList&lt;int&gt;&amp; Handler::indentations ()
  {
      return elementIndentation;
  }
  QStringList&amp; Handler::attributes ()
  {
      return elementAttributes;
  }
  QList&lt;int&gt;&amp; Handler::anzahl (){
      return elementAnzahl;
  }
  QStringList&amp; Handler::attributeName (){
      return elementAttributeName;
  }
  </code></pre>
  
  <p>handler.h:</p>
  
  <pre><code>#ifndef HANDLER_H
  #define HANDLER_H
  
  #include &lt;qxml.h&gt;
  #include "structs.h"
  #include "imageloader.h"
  #include &lt;qfile.h&gt;
  #include &lt;QDebug&gt;
  #include &lt;iostream&gt;
  
  class Handler : public QXmlDefaultHandler
  {
  public:
      bool startDocument();
      bool startElement(const QString &amp;, const QString &amp;, const QString &amp;qName,
                         const QXmlAttributes &amp;atts);
      bool endElement(const QString &amp;, const QString &amp;, const QString &amp;);
  
      bool fatalError(const QXmlParseException &amp;exception);
      QStringList&amp; attributes();
      QStringList&amp; names();
      QStringList&amp; attributeName();
      QList&lt;int&gt;&amp; anzahl();
      QList&lt;int&gt;&amp; indentations();
  
  private:
      int indentationLevel;
      QStringList elementName;
      QStringList elementAttributes;
      QStringList elementAttributeName;
      QList&lt;int&gt; elementAnzahl;
      QList&lt;int&gt; elementIndentation;
  };
  
  #endif
  </code></pre>