Errors while building a static libtorch

sterio: <p>I’m trying to build a static libtorch in a brand new conda environment, following the instruction in the README.md in the repository.</p>
<p>It builds during a while, but up to a point I have a bunch of errors:</p>
<pre><code class="lang-auto">onnx.lib(defs.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary' : value 'MT_StaticRelease
' doesn't match value 'MD_DynamicRelease' in core.obj 
onnx.lib(old.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary' : value 'MT_StaticRelease'
 doesn't match value 'MD_DynamicRelease' in core.obj
</code></pre>
<p>etc… it goes like this during a while, then a bunch of already defined symbols:</p>
<pre><code class="lang-auto">msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: __cdecl std::basic_streambuf&lt;char,struct std::char_trait
s&lt;char&gt; &gt;::basic_streambuf&lt;char,struct std::char_traits&lt;char&gt; &gt;(void)" (??0?$basic_streambuf@DU?$char_traits@D@
std@@@std@@IEAA@XZ) already defined in onnx.lib(defs.cc.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: virtual __cdecl std::basic_streambuf&lt;char,struct std::char_
traits&lt;char&gt; &gt;::~basic_streambuf&lt;char,struct std::char_traits&lt;char&gt; &gt;(void)" (??1?$basic_streambuf@DU?$char_tra
its@D@std@@@std@@UEAA@XZ) already defined in onnx.lib(defs.cc.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: virtual __cdecl std::basic_ios&lt;char,struct std::char_traits
&lt;char&gt; &gt;::~basic_ios&lt;char,struct std::char_traits&lt;char&gt; &gt;(void)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@U
EAA@XZ) already defined in onnx.lib(defs.cc.obj) [C:\Work\pytorch\pytorch_static\pytorch\build\caffe
2\torch\lib\libshm_windows\shm.vcxproj]
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: virtual __cdecl std::basic_ostream&lt;char,struct std::char_tr
aits&lt;char&gt; &gt;::~basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;(void)" (??1?$basic_ostream@DU?$char_traits@D@
std@@@std@@UEAA@XZ) already defined in onnx.lib(defs.cc.obj) [C:\Work\pytorch\pytorch_static\pytorch
\build\caffe2\torch\lib\libshm_windows\shm.vcxproj]
</code></pre>
<p>The output is really similar to this message in that issue:</p><aside class="onebox githubissue" data-onebox-src="https://github.com/pytorch/pytorch/issues/14203#issuecomment-440183660">
  <header class="source">

      <a href="https://github.com/pytorch/pytorch/issues/14203#issuecomment-440183660" target="_blank" rel="noopener nofollow ugc">github.com/pytorch/pytorch</a>
  </header>

  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewbox="0 0 14 16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/pytorch/pytorch/issues/14203#issuecomment-440183660" target="_blank" rel="noopener nofollow ugc">Building with Ninja + Cuda on Windows 10</a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2018-11-19" data-time="22:05:03" data-timezone="UTC">10:05PM - 19 Nov 18 UTC</span>
      </div>

        <div class="date">
          closed <span class="discourse-local-date" data-format="ll" data-date="2018-11-20" data-time="21:33:08" data-timezone="UTC">09:33PM - 20 Nov 18 UTC</span>
        </div>

      <div class="user">
        <a href="https://github.com/aman-tiwari" target="_blank" rel="noopener nofollow ugc">
          <img alt="aman-tiwari" src="https://avatars.githubusercontent.com/u/8798016?v=4" class="onebox-avatar-inline" width="20" height="20">
          aman-tiwari
        </a>
      </div>
    </div>

    <div class="labels">
    </div>
  </div>
</div>

  <div class="github-row">
    <p class="github-body-container">## 🐛 Bug

I'm trying to build Pytorch (to get LibTorch) on Windows 10.  Curren<span class="show-more-container"><a href="" rel="noopener" class="show-more">…</a></span><span class="excerpt hidden">tly I'm building with Visual Studio, but it's very slow.  The documentation suggests using Ninja, however if I `set CMAKE_GENERATOR=Ninja` I get the error `CUDA support not available with 32-bit windows. Did you  forget to set Win64 in the generator target`.

How do I get `Win64` set as the generator target when using Ninja? Or is Ninja + CUDA not possible on Windows 10?

## To Reproduce
Follow instructions here: https://pytorch.org/docs/master/notes/windows.html , including trying to use Ninja

Using Windows 10 + CUDA 9.0.</span></p>
  </div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>The Runtime Library errors really puzzle me, am I setting some flags wrong? I am not setting any flag that has anything to do with /MT or /MD though.</p>