I'm trying to make a program in Qt that receives an image from TCP and then finds an ArUco marker inside of it.
Everything works fine except for the ArUco library. Once I added a simple line defining a dictionary:
cv::aruco::Dictionary ArucoDic = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
I get the error:
undefined reference to cv::aruco::getPredefinedDictionary(cv::aruco::PredefinedDictionaryType)
The other people I've found with this problem are able to solve it by adding the library in the .pro file, but I did that from the beginning following these tutorials:
After all of that, my .pro file looks like this:
QT -= gui
QT += network
QT += core
CONFIG += c++17 console
CONFIG -= app_bundle
# 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 += \
main.cpp \
server.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
server.h
INCLUDEPATH += D:/OpenCV/opencv/release/install/include
LIBS += -LD:/OpenCV/opencv/release/install/x64/mingw/lib -lopencv_core480
LIBS += -LD:/OpenCV/opencv/release/install/x64/mingw/lib -lopencv_highgui480
LIBS += -LD:/OpenCV/opencv/release/install/x64/mingw/lib -lopencv_imgcodecs480
LIBS += -LD:/OpenCV/opencv/release/install/x64/mingw/lib -lopencv_imgproc480
LIBS += -LD:/OpenCV/opencv/release/install/x64/mingw/lib -lopencv_features2d480
LIBS += -LD:/OpenCV/opencv/release/install/x64/mingw/lib -lopencv_calib3d480
LIBS += -LD:/OpenCV/opencv/release/install/x64/mingw/lib -lopencv_aruco480
I don't really know what's the problem, since all libraries before opencv_aruco480 work perfectly fine.
I also know Qt is reading the ArUco library, since it is able to predict the functions I'm writing. It just isn't compiling.
It was solved by adding the objdetect.dll library. I also changed the way all libraries were referenced in the .pro file.
win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_core480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_highgui480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_imgcodecs480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_imgproc480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_features2d480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_calib3d480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_aruco480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_dnn480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_flann480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_gapi480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_ml480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_objdetect480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_photo480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_stitching480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_video480.dll win32: LIBS += -L$$PWD/../../OpenCV/opencv/release/install/x64/mingw/lib/ -llibopencv_videoio480.dll
INCLUDEPATH += $$PWD/../../OpenCV/opencv/release/install/include DEPENDPATH += $$PWD/../../OpenCV/opencv/release/install/include