title: Can't compile the static library project with visual studio 2017
body: <p>I was trying to build my own static library(.lib) using codes in <a href="https://wiki.unrealengine.com/Creating_%26_Linking_Static_Libraries_And_Make_Your_Own_Blueprint_Node_With_VS_2017_%26_UE4#Creating_the_static_library" rel="nofollow noreferrer">this tutorial</a>. But first of all, static library project will generate a <strong>stdafx.h</strong>, a <strong>targetver.h</strong> and a <strong>stdafx.cpp</strong> for me automatically, so I have to include stdafx.h in all my source files. But once I did that, the project still refuses to compile because now it thinks that <strong>YJMagic is not a class or namespace name</strong>. Then I checked the project's properties and found out the stdafx.h is already my precompiled header file. So maybe it won't compile because there is a double include problem?</p>
  
  <p>Then because I can't figure out a solution, I did it another way: I create an empty project, use the same source file and header file, then manually change the target extension to .lib, and configuration type to static library(.lib).(in <strong>properties</strong>-><strong>configuration properties</strong>-><strong>general</strong>), then hit build, aaaaaand it works!!!! And I wrote a small test script which proves the lib works fine...SO do I see the static library project wrong? I wonder is there anyone got the same problem or someone who can explain?</p>
  
  <p>For those who don't want to open the link to tuto, the source codes are there below:</p>
  
  <pre><code>#pragma once
  
  // YJMagic.h
  
  namespace YJMagic
  {
      class YJMagic
      {
      public:
          // Returns a + b
          static double Add(double a, double b);
      };
  }
  
  
  // YJMagic.cpp
  
  #include "YJMagic.h"
  
  #include &lt;stdexcept&gt;
  
  using namespace std;
  
  namespace YJMagic
  {
      double YJMagic::Add(double a, double b)
      {
          return a + b;
      }
  }
  </code></pre>
  
  <h2>Thanks in advance for your answer! Have a nice day;)</h2>
  
  <p>Update with references</p>
  
  <ul>
  <li><p><a href="http://www.cplusplus.com/forum/articles/10627/#msg49679" rel="nofollow noreferrer">Headers and includes: why and how</a></p></li>
  <li><p>Youtube: <a href="https://www.youtube.com/watch?v=Wt4dxDNmDA8" rel="nofollow noreferrer">Making and working with libs in cpp</a></p></li>
  </ul>