Why after linking the OpenCV libraries, Mat objects are still 'undefined'?
-
Hi
Have you tried with
INCLUDEPATH += -I\usr\includeas the includes already have the opencv4 name.
#include <opencv4/opencv2/core.hpp>also if you look inside the include folder, does it have the opencv2 sub folder ?
ahh. captial L. i need glasses :)
-
Hi
Have you tried with
INCLUDEPATH += -I\usr\includeas the includes already have the opencv4 name.
#include <opencv4/opencv2/core.hpp>also if you look inside the include folder, does it have the opencv2 sub folder ?
ahh. captial L. i need glasses :)
-
@mrjj I tried to change it the way you suggested and using -l instead of -L but I still get those errors.
-
Your paths are invalid, use forward slashes for them.
-
@SGaist @mrjj I changed the paths to this
INCLUDEPATH += -I/usr/include
LIBS += -l/usr/local/lib/libopencv_core.so
LIBS+= -l/usr/local/lib/libopencv_highgui.so
LIBS+= -l/usr/local/lib/libopencv_imgproc.so
Should it work now?
and did the cleaning process and now I have more errors but all because the libraries still seem to be unrecognised. -
How did you install OpenCV ?
Did you check that it is from the correct architecture ? -
Call "file /usr/local/lib/libopencv_core.so". What do you get ?
As for your .pro file:
LIBS += -L/usr/local/lib \ -lopencv_core \ -lopencv_highgui \ -lopencv_imgproc
should be enough to link to these OpenCV libraries.
-
@SGaist It was a 'symbolic link' to libopencv_imgproc.so.4.5.0, so I called it again for that and got:
file /usr/local/lib/libopencv_imgproc.so.4.5.0
/usr/local/lib/libopencv_imgproc.so.4.5.0: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=a9e4463d8bcc7f5051819e1ab34a131be7685cb3, not stripped -
Can you show your current .pro file content ?
-
@SGaist yes :
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++11 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ core.cpp \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui INCLUDEPATH += -I/usr/local/include LIBS += -L/usr/local/lib \ -lopencv_core \ -lopencv_highgui \ -lopencv_imgproc # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
-
That looks good. What exact error are you getting now, after doing a full rebuild ?
-
That's not a linking problem you have there.
Where is opencv2/core.hpp located exactly in your system ?
-
Did you notice the "opencv4" folder that is missing from your INCLUDEPATH statement ?
Either add it there or to your include statements.
-
Please provide the information directly.
What exactly did you try ?
What is the error your get ? -
@SGaist said in Why after linking the OpenCV libraries, Mat objects are still 'undefined'?:
Did you notice the "opencv4" folder that is missing from your INCLUDEPATH statement ?
Either add it there or to your include statements.
I wrote "either" which means one or the other, not both.