Loading pytorch model in C++, problem with libtorch.dll
I'm trying to load neural network model trained with pytorch to C++ program.
There is a tutorial how to do it, but can't get it working.

The console appears, and then I get,


  "The Code execution cannot proceed, because the object xxx.dll was not found".


Sometimes it is c10.dll, other time torch.dll, or caffe2.dll.

I checked my C/C++ and Linker properties like 50 times.
I checked it with using debug and release version of libtorch.
I ran it on Debug x86, Debug x64, Release x86, Release x64.
And I added those files manually to Debug folder (where .exe file is)
None of it worked.

This is my 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"; 
}


This is how I set directory for header files:

 $(SolutionDir)libtorch\include


...and linker directory for additional libraries:

$(SolutionDir)libtorch\lib


...and all .lib files I added:

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;


It's not that some function or classes from this library are not working. I cannot compile a simple "Hello World" program.

I even downloaded some random .dll file to check if it is this particular library problem, and other .dll worked with no problems.

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.

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.

I'm running VS 2017 Community, version 15.9.14 on Windows 10.

Ok, ive actually came up with solution by my own.

For some reasons which i completly do not understand i had to put .dll files in my project folder.
Setting up the path for additional libraries in linker properties seems to not work for those libraries, at least on my PC.

This is very confusing because other, random library which i downloaded for test, I can place wherever i want, all I need to do is just set up correct path in Linker properties.

But not THIS particular library (libtorch).

Anyway, problem is solved, hope that someday someone finds this usefull :)
