简体   繁体   中英

Qt and OpenCV linking error undefined reference in mat.inl.hpp

I use Qt creator with it's qmake system. I'm on Windows 10 and use MinGW.
I want to add some libs to my project and opencv is in the list.
This is my.pro file:

QT       += core gui 3dcore 3drender 3dextras multimedia multimediawidgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

SOURCES += \
main.cpp \
mainwindow.cpp \
paintedtextureimage.cpp \
scenemodifier.cpp

HEADERS += \
mainwindow.h \
paintedtextureimage.h \
scenemodifier.h

FORMS += \
mainwindow.ui

qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

win32: LIBS += -L'C:/Program Files (x86)/Intel RealSense SDK 2.0/lib/x64/' -lrealsense2

INCLUDEPATH += 'C:/Program Files (x86)/Intel RealSense SDK 2.0/include/'
DEPENDPATH += 'C:/Program Files (x86)/Intel RealSense SDK 2.0/include/'

win32:CONFIG(release, debug|release): LIBS += - 
L$$PWD/../../../Tools/OpenCV/opencv/build/x64/vc15/lib/ -lopencv_world411
else:win32:CONFIG(debug, debug|release): LIBS += - 
L$$PWD/../../../Tools/OpenCV/opencv/build/x64/vc15/lib/ -lopencv_world411d
else:unix: LIBS += -L$$PWD/../../../Tools/OpenCV/opencv/build/x64/vc15/lib/ -lopencv_world411

INCLUDEPATH += $$PWD/../../../Tools/OpenCV/opencv/build/include
DEPENDPATH += $$PWD/../../../Tools/OpenCV/opencv/build/include

This was generated automatically when I added libraries in GUI. I use binaries of OpenCV from site, so I have this opencv_world411.lib instead of a bunch of different.lib's for modules.

Now, when I

#include <opencv2/opencv.hpp>

in my code and try to do

cv::Mat mat;

It gives me errors:
undefined reference to cv::fastFree(void*)
undefined reference to cv::Mat::deallocate()

What did I wrong?

Got solution. I used opencv for vs compiler, but needed for MinGW.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM