对 cv::aruco::getPredefinedDictionary(cv::aruco::P redefinedDictionaryType) 的未定义引用

undefined reference to cv::aruco::getPredefinedDictionary(cv::aruco::PredefinedDictionaryType)

提问人:Daniel Bajo Collados 提问时间:11/16/2023 最后编辑:Abderrahmene Rayene MihoubDaniel Bajo Collados 更新时间:11/16/2023 访问量:20

问:

我正在尝试在Qt中创建一个程序,该程序从TCP接收图像,然后在其中找到一个ArUco标记。

除了 ArUco 库之外,一切正常。一旦我添加了定义字典的简单行:

cv::aruco::Dictionary ArucoDic = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);

我收到错误:

undefined reference to cv::aruco::getPredefinedDictionary(cv::aruco::PredefinedDictionaryType)

我发现的其他人可以通过在 .pro 文件中添加库来解决它,但我从一开始就按照以下教程这样做了:

完成所有这些之后,我的 .pro 文件如下所示:

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

我真的不知道问题出在哪里,因为opencv_aruco480之前的所有库都可以正常工作。

我也知道Qt正在阅读ArUco库,因为它能够预测我正在编写的函数。它只是没有编译。

C++ opencv qt-creator 未定义引用

评论

0赞 Christoph Rackwitz 11/16/2023
IDE能够自动完成,这与编译器拥有所有信息无关。单独的系统。-- 也包含正确的标题吗?
0赞 Daniel Bajo Collados 11/16/2023
源文件中的标头如下:#include < opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgcodecs/imgcodecs.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/aruco.hpp>

答:

0赞 Daniel Bajo Collados 11/21/2023 #1

通过添加objdetect.dll库解决了这个问题。 我还更改了 .pro 文件中引用所有库的方式。

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