title: Using tinyxml2 with a Visual Studio, Visual C++ MFC Application
body: <p>I'm trying to get accustomed to both MFC development and Visual Studio so I have installed Visual Studio 2012 RC and have created a simple MFC Application. Currently the application is little more than the MFC Wizard generated for me.</p>
  
  <p>I decided I wanted to incorporate an XML Library so I found <a href="https://github.com/leethomason/tinyxml2" rel="nofollow">this one on github</a>. I download the ZIP file with the source code, unzip it and then in Visual Studio I goto the solution explorer, choose my solution, right click and choose "Add" > "Existing Project". I select the project file for the source code and it appears in my Solution Explorer tree.</p>
  
  <p>I test the code compiles and it does. However I'm not quite sure how to use it from my current solution.</p>
  
  <p>I try to use this code in my doc:</p>
  
  <pre><code>#include "../../TinyXML2/leethomason-tinyxml2-a3efec0/tinyxml2.h"
  
  &lt;...snip...&gt;
  
  BOOL LoadDocumentFromXML(const CString&amp; filename) {
  
      CT2CA pszConvertedAnsiString (filename);
      std::string s(pszConvertedAnsiString);
  
      tinyxml2::XMLDocument doc(true);
      if (tinyxml2::XML_NO_ERROR != doc.LoadFile(s.c_str())) {
          return FALSE;
      }
  
  
  
      return TRUE;
  }
  </code></pre>
  
  <p>However  I get this linker error when I try to build the project:</p>
  
  <pre><code>------ Build started: Project: GraphApp, Configuration: Debug Win32 ------
    GraphAppDoc.cpp
  GraphAppDoc.obj : error LNK2019: unresolved external symbol "public: __thiscall tinyxml2::XMLDocument::XMLDocument(bool)" (??0XMLDocument@tinyxml2@@QAE@_N@Z) referenced in function "int __cdecl LoadDocumentFromXML(class ATL::CStringT&lt;wchar_t,class StrTraitMFC_DLL&lt;wchar_t,class ATL::ChTraitsCRT&lt;wchar_t&gt; &gt; &gt; const &amp;)" (?LoadDocumentFromXML@@YAHABV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)
  GraphAppDoc.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall tinyxml2::XMLDocument::~XMLDocument(void)" (??1XMLDocument@tinyxml2@@UAE@XZ) referenced in function "int __cdecl LoadDocumentFromXML(class ATL::CStringT&lt;wchar_t,class StrTraitMFC_DLL&lt;wchar_t,class ATL::ChTraitsCRT&lt;wchar_t&gt; &gt; &gt; const &amp;)" (?LoadDocumentFromXML@@YAHABV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)
  GraphAppDoc.obj : error LNK2019: unresolved external symbol "public: int __thiscall tinyxml2::XMLDocument::LoadFile(char const *)" (?LoadFile@XMLDocument@tinyxml2@@QAEHPBD@Z) referenced in function "int __cdecl LoadDocumentFromXML(class ATL::CStringT&lt;wchar_t,class StrTraitMFC_DLL&lt;wchar_t,class ATL::ChTraitsCRT&lt;wchar_t&gt; &gt; &gt; const &amp;)" (?LoadDocumentFromXML@@YAHABV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)
  C:\Users\Phill\Documents\Visual Studio 2012\Projects\GraphApp\Debug\GraphApp.exe : fatal error LNK1120: 3 unresolved externals
  ========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>In the solution explorer I select my MFC application project, right click and choose "Dependencies". I make sure the MFC app is set to be dependent on tinyxml project and I ensure the "Build Order" is correct (tinyxml first). I also goto into "References..." and add tinyxml there too. I even add the debug directory of tinyxml to my MFC app's include path in project properties as well. What am I missing please?</p>