title: Loading pytorch model in C++, problem with libtorch.dll
body: <p>I'm trying to load neural network model trained with pytorch to C++ program.
  There is a <a href="https://pytorch.org/tutorials/advanced/cpp_export.html" rel="nofollow noreferrer">tutorial</a> how to do it, but can't get it working.</p>
  
  <p>The console appears, and then I get,</p>
  
  <blockquote>
    <p>"The Code execution cannot proceed, because the object xxx.dll was not found".</p>
  </blockquote>
  
  <p>Sometimes it is c10.dll, other time torch.dll, or caffe2.dll.</p>
  
  <p>I checked my C/C++ and Linker properties like 50 times.<br>
  I checked it with using debug and release version of libtorch.<br>
  I ran it on Debug x86, Debug x64, Release x86, Release x64.<br>
  And I added those files manually to Debug folder (where .exe file is)<br>
  None of it worked.</p>
  
  <p>This is my code</p>
  
  <pre><code>#include "pch.h"
  #include &lt;torch/script.h&gt;
  #include &lt;memory&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      std::cout &lt;&lt; "Hello World!\n"; 
  }
  </code></pre>
  
  <p>This is how I set directory for header files:</p>
  
  <pre><code> $(SolutionDir)libtorch\include
  </code></pre>
  
  <p>...and linker directory for additional libraries:</p>
  
  <pre><code>$(SolutionDir)libtorch\lib
  </code></pre>
  
  <p>...and all .lib files I added:</p>
  
  <pre><code>torch.lib;onnxifi_loader.lib;onnxifi_dummy.lib;onnx_proto.lib;onnx.lib;libprotoc.lib;libprotobuf-lite.lib;libprotobuf.lib;foxi_loader.lib;foxi_dummy.lib;cpuinfo.lib;clog.lib;caffe2_module_test_dynamic.lib;caffe2_detectron_ops.lib;caffe2.lib;c10.lib;
  </code></pre>
  
  <p>It's not that some function or classes from this library are not working. I cannot compile a simple "Hello World" program.</p>
  
  <p>I even downloaded some random .dll file to check if it is this particular library problem, and other .dll worked with no problems.</p>
  
  <p>I set up the project manually, and followed the instruction from the link I sent (with creating project with CMAKE), and still I have this error.</p>
  
  <p>I'm working on it for few hours and I'm pretty annoyed about this.I ran out of ideas. I really don't know what else I could miss in this situation.</p>
  
  <p>I'm running VS 2017 Community, version 15.9.14 on Windows 10.</p>