Windows linker error

annoyed: <p>Im trying to building torch locally on Windows and I can’t get past this linker error:</p>
<p><code>FAILED: bin/torch_cpu.dll lib/torch_cpu.lib</code><br>
<code>cmd.exe /C “cd . &amp;&amp; “C:\Program Files\CMake\bin\cmake.exe” -E vs_link_dll --intdir=caffe2\CMakeFiles\torch_cpu.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  – C:\PROGRA~1\MICROS~1\2022\PROFES~1\VC\Tools\MSVC\1438~1.331\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\torch_cpu.rsp  /out:bin\torch_cpu.dll /implib:lib\torch_cpu.lib /pdb:bin\torch_cpu.pdb /dll /version:0.0 /machine:x64 /ignore:4049 /ignore:4217 /ignore:4099 /debug /INCREMENTAL:NO  -WHOLEARCHIVE:D:/Projects/workspace/Libtorch_Win/libtorch/build/lib/onnx.lib  &amp;&amp; cd .”</code><br>
<code>LINK: command “C:\PROGRA~1\MICROS~1\2022\PROFES~1\VC\Tools\MSVC\1438~1.331\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\torch_cpu.rsp /out:bin\torch_cpu.dll /implib:lib\torch_cpu.lib /pdb:bin\torch_cpu.pdb /dll /version:0.0 /machine:x64 /ignore:4049 /ignore:4217 /ignore:4099 /debug /INCREMENTAL:NO -WHOLEARCHIVE:D:/Projects/workspace/Libtorch_Win/libtorch/build/lib/onnx.lib /MANIFEST:EMBED,ID=2” failed (exit code 1120) with the following output:</code><br>
<code>Creating library lib\torch_cpu.lib and object lib\torch_cpu.exp</code><br>
<code>C10Kernel.cpp.obj : error LNK2001: unresolved external symbol “public: __cdecl c10d::Work::Work(int,enum c10d::OpType,char const *,class std::optional&lt;class std::vector&lt;class at::Tensor,class std::allocator &gt; &gt; const &amp;)” (??0Work@c10d@@QEAA@HW4OpType@1@PEBDAEBV?$optional@V?$vector@VTensor@at@@V?$allocator@VTensor@at@@@std@@@std@@@std@@@Z)</code><br>
<code>AutoFunctionalizeKernel.cpp.obj : error LNK2001: unresolved external symbol “public: __cdecl c10d::Work::Work(int,enum c10d::OpType,char const *,class std::optional&lt;class std::vector&lt;class at::Tensor,class std::allocator &gt; &gt; const &amp;)” (??0Work@c10d@@QEAA@HW4OpType@1@PEBDAEBV?$optional@V?$vector@VTensor@at@@V?$allocator@VTensor@at@@@std@@@std@@@std@@@Z)</code><br>
<code>HigherOrderKernel.cpp.obj : error LNK2001: unresolved external symbol “public: __cdecl c10d::Work::Work(int,enum c10d::OpType,char const *,class std::optional&lt;class std::vector&lt;class at::Tensor,class std::allocator &gt; &gt; const &amp;)” (??0Work@c10d@@QEAA@HW4OpType@1@PEBDAEBV?$optional@V?$vector@VTensor@at@@V?$allocator@VTensor@at@@@std@@@std@@@std@@@Z)</code><br>
<code>ExecutionFrame.cpp.obj : error LNK2001: unresolved external symbol “public: __cdecl c10d::Work::Work(int,enum c10d::OpType,char const *,class std::optional&lt;class std::vector&lt;class at::Tensor,class std::allocator &gt; &gt; const &amp;)” (??0Work@c10d@@QEAA@HW4OpType@1@PEBDAEBV?$optional@V?$vector@VTensor@at@@V?$allocator@VTensor@at@@@std@@@std@@@std@@@Z)</code><br>
<code>GraphExecutorBase.cpp.obj : error LNK2001: unresolved external symbol “public: __cdecl c10d::Work::Work(int,enum c10d::OpType,char const *,class std::optional&lt;class std::vector&lt;class at::Tensor,class std::allocator &gt; &gt; const &amp;)” (??0Work@c10d@@QEAA@HW4OpType@1@PEBDAEBV?$optional@V?$vector@VTensor@at@@V?$allocator@VTensor@at@@@std@@@std@@@std@@@Z)</code><br>
<code>OpKernel.cpp.obj : error LNK2001: unresolved external symbol “public: __cdecl c10d::Work::Work(int,enum c10d::OpType,char const *,class std::optional&lt;class std::vector&lt;class at::Tensor,class std::allocator &gt; &gt; const &amp;)” (??0Work@c10d@@QEAA@HW4OpType@1@PEBDAEBV?$optional@V?$vector@VTensor@at@@V?$allocator@VTensor@at@@@std@@@std@@@std@@@Z)</code><br>
<code>SerialGraphExecutor.cpp.obj : error LNK2001: unresolved external symbol “public: __cdecl c10d::Work::Work(int,enum c10d::OpType,char const *,class std::optional&lt;class std::vector&lt;class at::Tensor,class std::allocator &gt; &gt; const &amp;)” (??0Work@c10d@@QEAA@HW4OpType@1@PEBDAEBV?$optional@V?$vector@VTensor@at@@V?$allocator@VTensor@at@@@std@@@std@@@std@@@Z)</code><br>
<code>bin\torch_cpu.dll : fatal error LNK1120: 1 unresolved externals</code></p>
<p>I’m doing:</p>
<p>set CMAKE_BUILD_TYPE=Release<br>
set BUILD_SHARED_LIBS=ON<br>
set USE_CUDA=ON<br>
set USE_DISTRIBUTED=OFF<br>
set USE_GLOO=OFF<br>
set USE_MPI=OFF<br>
python tools/build_libtorch.py</p>
<p>I’m using:<br>
torch (Checking out Revision ba56102387ef21a3b04b357e5b183d48f0afefc7 (v2.8.0))<br>
cuda12.2<br>
Visual Studio 2022 Developer Command Prompt v17.8.23</p>
<p>Suggestions say to turn off distributed, which I have done, but it doesn’t help.  Any ideas?</p>