title: C++ DLL: unresolved external symbol
body: <p>I seem to have some issues with creating new files for my project. </p>
  
  <p>The issue is that in my <code>sk_error.h</code> file it seems to complain about <code>unresolved external symbols</code> (full error report below). When I place my <code>OutOfRange</code> class in my <code>sk_interface.h</code> file no one complains but when I put the class in the errors file it has issues with it. </p>
  
  <p>If I was to comment out <code>OutOfRange</code> it works perfectly fine so I dont think that it is an issue with the DLL setup.</p>
  
  <p><strong>sk_error.h</strong></p>
  
  <pre><code>#include &lt;sk_platform.h&gt;
  #include &lt;sk_interface.h&gt;
  
  namespace sky {
      class SK_API OutOfRange : IError {
      public:
          OutOfRange() {
              m_message = " Out Of Range";
              m_value = (0 &lt;&lt; 1);
          }
          std::string getMessage() override {
              return m_message;
          }
      };
  }
  </code></pre>
  
  <p><strong>sk_platform.h</strong></p>
  
  <pre><code>#if defined (SK_NONCLIENT_BUILD)
          #ifndef SK_API
              #define SK_API __declspec(dllexport)
          #endif
      #else
          #ifndef SK_API
              #define SK_API __declspec(dllimport)
          #endif
  #endif
  </code></pre>
  
  <p><strong>sk_interface.h</strong></p>
  
  <pre><code>#include &lt;sk_platform.h&gt;
  #include &lt;string&gt;
  
  namespace sky {
  
      ...
  
      class SK_API IError {
      public:
          virtual std::string getMessage() = 0;
      protected:
          uint32_t m_value = 0;
          std::string m_message = "Error not initialized";
      };
  
  }
  </code></pre>
  
  <p><strong>The Client Project using the DLL</strong></p>
  
  <pre><code>#include &lt;sk_logmanager.h&gt;
  #include &lt;sk_error.h&gt;
  #include &lt;iostream&gt;
  
  int main() {
      sky::g_LogManager.startup();
      sky::OutOfRange err;
      std::cout &lt;&lt; err.getMessage() &lt;&lt; "\n";
      sky::g_LogManager.shutdown();
      while (1) {}
  }
  </code></pre>
  
  <p><strong>Error Output</strong></p>
  
  <pre><code>1&gt;------ Build started: Project: SkyTest, Configuration: Debug Win32 ------
  1&gt;main.cpp
  1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sky::OutOfRange::OutOfRange(void)" (__imp_??0OutOfRange@sky@@QAE@XZ) referenced in function _main
  1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; __thiscall sky::OutOfRange::getMessage(void)" (__imp_?getMessage@OutOfRange@sky@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function _main
  1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sky::OutOfRange::~OutOfRange(void)" (__imp_??1OutOfRange@sky@@QAE@XZ) referenced in function _main
  1&gt;C:\Users\Matt\Documents\Game Development\DevEnv\SkyTest\Debug\SkyTest.exe : fatal error LNK1120: 3 unresolved externals
  1&gt;Done building project "SkyTest.vcxproj" -- FAILED.
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>Edit:</p>
  
  <p>I am using Visual Studio 2017 (could be the source of the error). The Client Project is using the .lib file.</p>