0

I am using openCV in some code I am attempting to build in QT creator (Qt version 5.15.2). I believe I am linking to all libraries etc correctly but I keep getting a ton of errors regarding undefined references to various cv::** items. I pasted a sample from one file below specifically implicating VideoWriter. I am guessing this is something very simple but I am new to Qt and Cv.

 error: undefined reference to `cv::VideoWriter::VideoWriter()'
 error: undefined reference to `cv::VideoWriter::fourcc(char, char, char, char)'
error: undefined reference to `cv::VideoWriter::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, double, cv::Size_<int>, bool)'

My includes for the above file are

#include "backend.h"
#include <QDebug>
#include <QFileDialog>
#include <QApplication>

#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QThread>
#include <QObject>
#include <QVariant>
#include <QDir>
#include <QVector>
#include <QUrl>
#include <QString>
#include <QDateTime>
#include <QStandardItemModel>
#include <QStandardItem>
#include <QModelIndex>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>

#include "miniscope.h"
#include "behaviorcam.h"
#include "controlpanel.h"
#include "datasaver.h"
#include "behaviortracker.h"
#include "tracedisplay.h"

And my pro file is as follows

QT += qml quick widgets
CONFIG += c++11

QT += 3dcore


# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Refer to the documentation for the
# deprecated API to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

#DEFINES += DEBUG
#DEFINES += USE_USB
DEFINES += USE_PYTHON

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
        backend.cpp \
        behaviorcam.cpp \
        behaviortracker.cpp \
        behaviortrackerworker.cpp \
        controlpanel.cpp \
        datasaver.cpp \
        main.cpp \
        miniscope.cpp \
        newquickview.cpp \
        tracedisplay.cpp \
        videodevice.cpp \
        videodisplay.cpp \
        videostreamocv.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =

# Add Icon
RC_ICONS = miniscope_icon.ico

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

HEADERS += \
    backend.h \
    behaviorcam.h \
    behaviortracker.h \
    behaviortrackerworker.h \
    controlpanel.h \
    datasaver.h \
    miniscope.h \
    newquickview.h \
    tracedisplay.h \
    videodevice.h \
    videodisplay.h \
    videostreamocv.h

DISTFILES += \
    ../Python/DLCwrapper.py \
    ../Scripts/DLCwrapper.py \
    ../deviceConfigs/behaviorCams.json \
    ../deviceConfigs/miniscopes.json \
    ../deviceConfigs/userConfigProps.json \
    ../deviceConfigs/videoDevices.json

win32 {
    # Path to your openCV .lib file(s)
    LIBS += -LC:/Users/holdb/OneDrive/Documents/opencv/build/x64/vc15/lib -lopencv_world440



    # Path to openCV header files
     INCLUDEPATH += C:/Users/holdb/OneDrive/Documents/opencv/build/include
    # INCLUDEPATH += C:/Users/holdb/OneDrive/Documents/opencv/build/include/opencv2

    # For Python
    #INCLUDEPATH += C:/Users/holdb/anaconda3/envs/python38
    INCLUDEPATH += C:/Users/holdb/anaconda3/envs/python38/include
    LIBS += -LC:/Users/holdb/anaconda3/envs/python38/libs -lpython38

    # For numpy
    INCLUDEPATH += LC:/Users/holdb/anaconda3/envs/python38/Lib/site-packages/numpy/core/include
}

Any help greatly appreciated!

hw22s
  • 13
  • 5

0 Answers0