title: How to build a non-MFC C++ project with static linking to VC run-time libraries?
body: <p>I know that for an MFC project built with Visual Studio, one can go to the project properties and then <code>Configuration Properties</code> -> <code>General</code> -> <code>use of MFC</code> and change it to <code>Use MFC in a static library</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/4L7F5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4L7F5.png" alt="enter image description here"></a></p>
  
  <p>This works if the resulting build has to run in earlier versions of Windows without the need to install MFC or VC run-time DLLs. The resulting build will use DLLs that are already present in every installation of Windows since Windows 7 and up. (Possibly even down to Windows XP.)</p>
  
  <p>Now if I create a non-MFC project, say a test C++ console application, the setting to use MFC is configured as "Use standard Windows Libraries":</p>
  
  <p><a href="https://i.stack.imgur.com/LVjDa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LVjDa.png" alt="enter image description here"></a></p>
  
  <p>But if I run the resulting binary file, say on a fresh install of Windows 7, I get this error:</p>
  
  <p><a href="https://i.stack.imgur.com/xo7PZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xo7PZ.png" alt="enter image description here"></a></p>
  
  <p>So having dug around the settings, I couldn't find any way to compile it with static linking to all those newer versions of VC RT libraries. Is it there and I just don't see it?</p>
  
  <p>PS. Having dug in further, I found out that I can change the "Platform Toolset" to <code>Visual Studio 2017 - Windows XP (v141_xp)</code>, assuming that it will make it backwards compatible with Windows XP and up:</p>
  
  <p><a href="https://i.stack.imgur.com/aL16E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aL16E.png" alt="enter image description here"></a></p>
  
  <p>But then if I compile it, I'm getting these errors:</p>
  
  <pre><code>1&gt;c:\program files (x86)\microsoft sdks\windows\v7.1a\include\objbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
  1&gt;c:\program files (x86)\microsoft sdks\windows\v7.1a\include\dbghelp.h(1540): warning C4091: 'typedef ': ignored on left of '' when no variable is declared
  1&gt;c:\program files (x86)\microsoft sdks\windows\v7.1a\include\dbghelp.h(3056): warning C4091: 'typedef ': ignored on left of '' when no variable is declared
  </code></pre>
  
  <p>In this part of <code>ObjBase.h</code> file which has nothing to do with my test C++ console project that I just created from a Visual Studio template:</p>
  
  <p><a href="https://i.stack.imgur.com/8uqyZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8uqyZ.png" alt="enter image description here"></a></p>
  
  <p>So my question is -- can I build a non-MFC C++ project that can run on older versions of Windows without the need to install VC Runtime or any other additional libraries?</p>