新建 libtorch.pri
在libtorch的根目录中,新建libtorch.pri (名字随便起)

libtorch.pri 内容如下:
INCLUDEPATH += "C:/libtorch/include"
INCLUDEPATH += "C:/libtorch/include/torch/csrc/api/include"
LIBS += "C:/libtorch/lib/*.lib"
QMAKE_LFLAGS += -INCLUDE:?warp_size@cuda@at@@YAHXZ
QMAKE_LFLAGS += -INCLUDE:?searchsorted_cuda@native@at@@YA?AVTensor@2@AEBV32@0_N1@Z
QMAKE_LFLAGS += /machine:x64
添加环境变量

工程中使用

示例

避免报错
#undef slots
#include <torch/torch.h>
#define slots Q_SLOTS
3712

被折叠的 条评论
为什么被折叠?



