Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors while using Libtorch + OpenCV + QT Creator

I have the following configuration in the .pro file

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += thread

SOURCES += main.cpp

INCLUDEPATH += /usr/local/include/opencv4
LIBS += -L/usr/local/lib/
LIBS += -lopencv_core
LIBS += -lopencv_highgui
LIBS += -lopencv_imgproc
LIBS += -lopencv_videoio

QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0

INCLUDEPATH += /path/to/libtorch/include
INCLUDEPATH += /path/to/libtorch/include/torch/csrc/api/include
LIBS += -L/path/to/libtorch/lib
LIBS += -ltorch -lc10

OpenCV works absolutely fine without "QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0". With this, however, I get this following errors:

enter image description here

OpenCV works fine with "QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=1" as well. But it throws a different set of errors:

enter image description here

Setting "QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0" has been recommended for Libtorch in most of the forums to avoid the errors above.

What could be a solution or some solutions to work around this? (I am a newbie to both Libtorch and Qt Creator.)

like image 528
Saptarshi Avatar asked Jul 24 '19 13:07

Saptarshi


Video Answer


1 Answers

Maybe OpenCV and Libtorch were compiled with a different version of GCC (and different values of _GLIBCXX_USE_CXX11_ABI).

Try recompiling them by yourself and see if things change.

like image 158
Doch88 Avatar answered Oct 06 '22 16:10

Doch88