Can I create libtorch c++ project using qt with qmake?

Can I create libtorch c++ project using qt with qmake?

Hi, did you find an answer?
Thanks,

I never personally used it but if you link the libtorch.so and libc10.so according to the conventions of qmake and include the header search path it should be possible.

Yes, that works well.
I tried with Qt and cmake, I didn’t find how to compile the project so I switched to qmake.

Win10:

QT += core gui concurrent

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

QMAKE_CXXFLAGS += -DGLIBCXX_USE_CXX11_ABI=0
CONFIG += no_keywords

DEFINES += QT_DEPRECATED_WARNINGS

#
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    
HEADERS += \
   

win32:CONFIG(release, debug|release): LIBS += -L/libtorch-win-shared-with-deps-1.4.0/libtorch/lib/ -ltorch -lc10
else:win32:CONFIG(debug, debug|release): LIBS += -L/libtorch-win-shared-with-deps-1.4.0/libtorch/lib/ -ltorchd -lc10d

INCLUDEPATH += libtorch-win-shared-with-deps-1.4.0/libtorch/include
DEPENDPATH += libtorch-win-shared-with-deps-1.4.0/libtorch/include

INCLUDEPATH += $/libtorch-win-shared-with-deps-1.4.0/libtorch/include/torch/csrc/api/include
DEPENDPATH += $/libtorch-win-shared-with-deps-1.4.0/libtorch/include/torch/csrc/api/include
1 Like