I’ve first tried building using the usual Visual Studio solution,
and then make a fresh project using a CMake file.
Strangely, getting the exact same behavior in either case. The libraries are connected, the include directories are specified, the code compiles. Until I try to construct the Net object
Caused by downloading the wrong version of Libtorch.
I was compiling stuff in Visual Studio solution in Debug mode, but downloaded Release mode of Libtorch from the website. Needed the Debug instead.
Did you achieve execute the program in release mode? i’m facing the same problem, it works fine in debug mode, but not in release when using the release distribution that you first downloaded. Tried with older release versions, but the problem persists
Finally, I’m copying all the .dll files from C:\src\libtorch\Release\lib\ into the folder where my executable will be. I do it in Visual studio via Project Properties->Post-Build Events-> Command Line:
I’m using C++20 and the toolset, which the Libtorch doesn’t quite like, because it’s made for C++14. So I’m using a precompiled header (header that is included before any other header), where I wrap the #include <torch/torch> with several pragma-warning-disables.