Problem when using Libtorch with Qt
-
wrote on 9 Jun 2023, 14:52 last edited by ZINE 6 Sept 2023, 14:53
Hi all,
I would like to use the PyTorch C++ distribution "libtorch" with my Qt application. I have Qt 5.9.5 and Ubuntu 18.04.
First, I downloaded and unzipped the libtorch library using the below Pytorch selection.Then, I created a basic Qt application where I added the necessary flags and library paths in the .pro file, as shown below.
I build and run the basic code below:
However, I got the following errors:
What is the issue because I consider that I added all the necessary flags and paths ??
-
Hi all,
I would like to use the PyTorch C++ distribution "libtorch" with my Qt application. I have Qt 5.9.5 and Ubuntu 18.04.
First, I downloaded and unzipped the libtorch library using the below Pytorch selection.Then, I created a basic Qt application where I added the necessary flags and library paths in the .pro file, as shown below.
I build and run the basic code below:
However, I got the following errors:
What is the issue because I consider that I added all the necessary flags and paths ??
Hi,
Did you first try to build the torch example described here ?
-
@ZINE then I would recommend to keep using CMake and build your Qt project with it especially since qmake has been deprecated with Qt 6.
Otherwise, check the flags used by cmake. Also note that the example uses C++14, something that you did not activate in your qmake project.
-
@ZINE then I would recommend to keep using CMake and build your Qt project with it especially since qmake has been deprecated with Qt 6.
Otherwise, check the flags used by cmake. Also note that the example uses C++14, something that you did not activate in your qmake project.
Which of these two torch libs did you download? According to your pro-file (QMAKE_CXXFLAGS += -DGLIBCXX_USE_CXX_ABI=0) it must be the first one (Pre-cxx11 ABI)
-
@ZINE then I would recommend to keep using CMake and build your Qt project with it especially since qmake has been deprecated with Qt 6.
Otherwise, check the flags used by cmake. Also note that the example uses C++14, something that you did not activate in your qmake project.
wrote on 9 Jun 2023, 19:49 last edited by@SGaist I build similar example that uses C++ 17 and it works fine with CMake.
How to activate C++14 in the qmake project ?
How to use CMake to build a Qt project ? Is there a way in Qt to automate the creation of CMakeLists.txt (packages, sources ...etc) and use CMake to build Qt project ?
-
Which of these two torch libs did you download? According to your pro-file (QMAKE_CXXFLAGS += -DGLIBCXX_USE_CXX_ABI=0) it must be the first one (Pre-cxx11 ABI)
wrote on 9 Jun 2023, 20:02 last edited by@Christian-Ehrlicher Yes, it is the first one that I used.
-
@Christian-Ehrlicher Yes, it is the first one that I used.
@ZINE But why? Remove this crappy define and use the correct lib with correct cxxabi support.
-
@ZINE But why? Remove this crappy define and use the correct lib with correct cxxabi support.
wrote on 12 Jun 2023, 05:07 last edited byIt works when I select libtorch that supports cxxabi and delete the define in the .pro file:
#QMAKE_CXXFLAGS += -DGLIBCXX_USE_CXX11_ABI=0.Thank you @Christian-Ehrlicher.
-
1/9