PyTorch C++ API binary compiled with xmake crashes

Hi,all

Today I created a manual_seed_test project. Then the content of xmake.lua is as follows

-- set xmake minimum version
set_xmakever("2.7.3")

-- set common flags
set_languages("c++17")
set_warnings("more")


add_requires("cmake::Torch", {alias = "libtorch", system = true, configs = {shared=false, envs = {CMAKE_PREFIX_PATH = "D:/3rdparty/libtorch-win-shared-with-deps-2.3.1+cu118/libtorch"}}})
add_packages("libtorch")


add_rules("mode.debug", "mode.release")

target("manual_seed_test")
    set_kind("binary")
    add_files("src/*.cpp")

The contents of main.cpp are as follows:

#include <iostream>

#include <torch/torch.h>

using namespace std;

int main(int argc, char** argv)
{
    try {
       torch::manual_seed(0);
        auto random_tensor = torch::rand({4, 3, 384, 288});
        std::cout << "Random tensor shape: " << random_tensor.sizes() << std::endl;
    } catch (std::exception &e) {
        std::cout << e.what() << std::endl;
    }

    return 0;
}

run code , as follows:

xmake b manual_seed_test && xmake r manual_seed_test

run result as follows:

checking for Microsoft Visual Studio (x64) version ... 2022
[ 25%]: cache compiling.release src\main.cpp
[ 50%]: linking.release manual_seed_test.exe
[100%]: build ok!
error: execv(D:\manual_seed_test\build\windows\x64\release\manual_seed_test.exe) failed(-1073741819)

The specific content of the project is as follows:
image

I use the same xmake and libtorch versions as others. It works on other people’s computers, but mine gives an error. How can I solve this problem? I have used Dependency walker to analyze manual_seed_test.exe and followed the solution in the Microsoft community, but it still doesn’t work. Please help me, I’d be grateful.