Libtorch program crashes at startup

I have been quite eager to try out libtorch C++, but I can’t seem to get it to work properly.
I am using cmake 3.12.0-rc1 and MSVC-15 compiler to build the program but the application seems to crash at start.
I am using libtorch-cpu-only release version.
Although the build is successful, there are lots of warnings during the build process.

You can find the build log here

main.cpp :

#include <iostream>
    #include <torch/torch.h>
    int main() {
        std::cout << "Hello libtorch c++!" << std::endl;
        torch::Tensor tensor = torch::rand({2, 3});
        std::cout << tensor << std::endl;
        return 0;

CMakelists.txt :

cmake_minimum_required(VERSION 3.12)
    # set(CMAKE_CXX_STANDARD 17)
    set(Torch_DIR "E:/libtorch/share/cmake/Torch")
    find_package(Torch REQUIRED)
    add_executable(sampleC main.cpp)
    target_link_libraries(sampleC "${TORCH_LIBRARIES}")
    set_property(TARGET sampleC PROPERTY CXX_STANDARD 11)

Program output:

    Process finished with exit code -1073741515 (0xC0000135)

I have been trying to solve this for two days now. But I had no luck.
Any help is appreciated.

Googling the exit code turns up STATUS_DLL_NOT_FOUND as the translation. You probably need to put the torch dll(s) in the search path (PATH?) or in your program folder or so.

Best regards


Yeah… that was the problem…now it’s working …thanks…

Thanks, this was very helpful. My gosh this industry is so much more complicated compared to when I tinted windows.