LINK errors VS 2015


I am not able to build the simplest C++ project, using TorchLib and 32bit Visual Studio 2015.
I downloaded the newest TorchLib library without CUDA support, and built the dependencies using the following cmake code on windows (taken from Pytorch website):
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

find_package(Torch REQUIRED)

add_executable(test-app test.cpp)
target_link_libraries(test-app ${TORCH_LIBRARIES})
set_property(TARGET test-app PROPERTY CXX_STANDARD 11)

Cmake generates without an error. When I try to build a file containing #include “torch/script.h” in VS2015, 21 different LINK errors occur (LINK2001, LINK1120, LINK2019). Errors are always some “unresolved external symbol ‘symbol’ referenced in function ‘…’”. What am I doing wrong? Are there other libraries needed? Wrong VS version?

@peterjc123 Would you like to help with this?

Also might be helpful.

You have to switch the configuration to Release and x64. And make sure you add the lib dir of libtorch to the project settings. The link given by @yf225 is a good example of using VS with libtorch.