Can i use Libtorch library on QT Creator with qmake?
-
Hi and welcome to devnet,
Did you follow the link provided in your GitHub issue ?
It seems that "CONFIG += no_keywords" added to your .pro file should do the trick.
[edit: Fixed the .pro file line SGaist]
-
Hi
Its seems it's not available for Windows with mingw/visual studio. (c++)
vs could work as @SGaist found. with workaround.
https://github.com/pytorch/pytorch/issues/19405
However, it being a python thing, could you not use it natively with Qt for Python ?
https://www.qt.io/qt-for-python -
new .pro file:
QMAKE_CXXFLAGS += -DGLIBCXX_USE_CXX11_ABI=0
CONFIG += no_keywordsINCLUDEPATH += "$$PWD\libtorch\include"
INCLUDEPATH += "$$PWD\libtorch\include\torch\csrc\api\include"LIBS += -L$$PWD/libtorch/lib
LIBS += -ltorch -lc10and i added to code:
#undef slots
#include "torch/torch.h"
#include "torch/script.h"
#def slots Q_SLOTSIt does not work. It gives same error.
-
What version of Qt are you using ?
What compiler are you using ?
Which version of the compiler ?Also, use forward slashes for paths. Qt handles the transformation to native path and it will avoid escaping issues.
-
QT Creator 4.8.2
MinGW 7.3.0 64 bitI adjusted forward slashes for paths.
-
@mesut.toruk said in Can i use Libtorch library on QT Creator with qmake?:
QT Creator 4.8.2
This is not Qt version...
"I adjusted forward slashes for paths." - and rerun qmake and rebuild?
-
Might be silly question but do you currently have a MinGW build of lib torch ?
-
QT 5.12.2.
No, i do not have MinGW build of lib torch. Then this post, i looked for it. It seems hard. They recommend using MSVC. I installed Visual Studio 2017 and tried to set compiler. I guess, I couldn't do it right. How can i add MSVC 2017 to Tools>Options>Kits>Compilers?My error:
13:21:15: Could not determine which "make" command to run. Check the "make" step in the build configuration. Error while building/deploying project t2 (kit: Desktop Qt 5.12.2 MSVC2017 64bit) When executing step "qmake"
-
@mesut.toruk said in Can i use Libtorch library on QT Creator with qmake?:
How can i add MSVC 2017 to Tools>Options>Kits>Compilers?
You cannot. Creator auto-detects it. Where did you install Visual Studio 2017? Did you install the C++ compiler too?
Regards
-
Hi @mesut.toruk,
I installed C:/Program Files/Microsoft Visual Studio. I also installed C++ compiler. It is "cl.exe" in Visual Studio.
And the compiler is not auto-detected in Tools > Options > Kits > Compilers ?
-
@aha_1980
No it is not. Should Qt install MSVC? While i install QT, i marked MSVC. But there is no MSVC in C:\Qt\Tools. However, there is qmake in C:\Qt\5.12.2\msvc2017\bin. I installed externally Visual Studio and tried to add it. It gives error. -
@mesut.toruk said in Can i use Libtorch library on QT Creator with qmake?:
Should Qt install MSVC
No, QtCreator should auto detect Microsoft C++ compiler. Can you show your compiler tab?
Which Visual Studio version did you install? -
@mesut.toruk The Microsoft compilers were not auto detected.
Did you install the C++ parts of Visual Studio (those are not automatically installed)?
If so, then try to deinstall QtCreator and install it again.