title: First C++ program can't compile - Unsure where to put third party lib
body: <p>I'm designing my first C++ program but I'm having a hard time understanding how to install and use a third party library called pugixml.</p>
  
  <p>Here is my structure:</p>
  
  <ul>
  <li>root/Makefile</li>
  <li>root/src/main.cpp</li>
  <li>root/include/pugi/pugixml.hpp</li>
  <li>root/include/pugi/pugixml.cpp</li>
  <li>root/include/pugi/pugiconfig.hpp</li>
  </ul>
  
  <p>I believe I was meant to dump all the pugixml in a folder called pug in my includes folder and then refer to it from my Makefile like this;</p>
  
  <pre><code>CC = g++
  CFLAGS = -g -Wall -std=c++11
  SRC = src
  INCLUDES = include
  TARGET = main
  
  all: $(TARGET)
  
  $(TARGET): $(SRC)/$(TARGET).cpp pugi/pugixml.cpp
      $(CC) $(CFLAGS) -I $(INCLUDES) -o $@ $^ 
  
  clean:
      $(RM) $(TARGET)
  </code></pre>
  
  <p>However when I run the Makefile or get this error:</p>
  
  <pre><code>main in main-bf0b72.o
    "pugi::xml_node::children(char const*) const", referenced from:
        _main in main-bf0b72.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [main] Error 1
  </code></pre>
  
  <p>This I've been told is due to thee fact that I have put the pugi cpp file in includes.</p>
  
  <p><strong>Question</strong></p>
  
  <ul>
  <li>Where should the various pugi files go, if not where I have put them?</li>
  <li>How should I modify my Makefile accordingly?</li>
  </ul>
  
  <p><strong>Code Edit</strong></p>
  
  <pre><code>#include "pugi/pugixml.hpp"
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;map&gt;
  
  int main() {
      pugi::xml_document doca, docb;
      std::map&lt;std::string, pugi::xml_node&gt; mapa, mapb;
  
      if (!doca.load_file("a.xml") || !docb.load_file("b.xml"))
          return 1;
  
      for (auto&amp; node: doca.child("site_entries").children("entry")) {
          const char* id = node.child_value("id");
          mapa[id] = node;
      }
  
      for (auto&amp; node: docb.child("site_entries").children("entry"))
          const char* idcs = node.child_value("id");
          if (!mapa.erase(id)) {
              mapb[id] = node;
          }
      }
  </code></pre>