Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenCV linking undefined References
Forum Updated to NodeBB v4.3 + New Features

OpenCV linking undefined References

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IJoulz
    wrote on last edited by IJoulz
    #1

    Hi all,

    i have read many already existing topics, but i haven't found one that fixes my issue.

    I want to use OpenCV in my project but i can not resolve some undefined references.
    I am using the default 'Desktop Qt 6.6.0 MinGW 64-bit' kit.

    .pro:

    ...
    win32:CONFIG(release, debug|release): LIBS += -L$$(OpenCV_DIR)/x64/vc16/lib/ -lopencv_world480
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$(OpenCV_DIR)/x64/vc16/lib/ -lopencv_world480d
    
    INCLUDEPATH += $$(OpenCV_DIR)/include
    DEPENDPATH += $$(OpenCV_DIR)/include
    ...
    

    Usage of OpenCV in a class:

    ...
    #include <opencv2/opencv.hpp>
    
    class OpenCVHelper : public QObject
    {
        Q_OBJECT
    
    public:
        OpenCVHelper();
        ~OpenCVHelper();
    
        cv::Mat m_rawCameraImage;
        cv::VideoCapture m_camera;
    };
    

    Errors:

    • undefined reference to `cv::Mat::Mat()'
    • undefined reference to `cv::VideoCapture::VideoCapture()'
    • ... and some other Stuff like their respective destructors.

    The OpenCV_DIR Enviroment variable holds 'C:\OpenCV\opencv\build'.
    1c76a8b8-e21f-413b-9ff1-112e9fc7c27f-grafik.png

    Can someone point me in the correct direction, how i can include this lib correctly?
    (The Includepath works btw)

    Thank you in advance.

    Christian EhrlicherC 1 Reply Last reply
    0
    • I IJoulz

      Hi all,

      i have read many already existing topics, but i haven't found one that fixes my issue.

      I want to use OpenCV in my project but i can not resolve some undefined references.
      I am using the default 'Desktop Qt 6.6.0 MinGW 64-bit' kit.

      .pro:

      ...
      win32:CONFIG(release, debug|release): LIBS += -L$$(OpenCV_DIR)/x64/vc16/lib/ -lopencv_world480
      else:win32:CONFIG(debug, debug|release): LIBS += -L$$(OpenCV_DIR)/x64/vc16/lib/ -lopencv_world480d
      
      INCLUDEPATH += $$(OpenCV_DIR)/include
      DEPENDPATH += $$(OpenCV_DIR)/include
      ...
      

      Usage of OpenCV in a class:

      ...
      #include <opencv2/opencv.hpp>
      
      class OpenCVHelper : public QObject
      {
          Q_OBJECT
      
      public:
          OpenCVHelper();
          ~OpenCVHelper();
      
          cv::Mat m_rawCameraImage;
          cv::VideoCapture m_camera;
      };
      

      Errors:

      • undefined reference to `cv::Mat::Mat()'
      • undefined reference to `cv::VideoCapture::VideoCapture()'
      • ... and some other Stuff like their respective destructors.

      The OpenCV_DIR Enviroment variable holds 'C:\OpenCV\opencv\build'.
      1c76a8b8-e21f-413b-9ff1-112e9fc7c27f-grafik.png

      Can someone point me in the correct direction, how i can include this lib correctly?
      (The Includepath works btw)

      Thank you in advance.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @IJoulz said in OpenCV linking undefined References:

      I am using the default 'Desktop Qt 6.6.0 MinGW 64-bit' kit.

      Why do you try to link against msvc libs then?

      LIBS += -L$$(OpenCV_DIR)/x64/vc16/lib/ -lopencv_world480

      You can not mix MSVC and MinGW c++ libraries.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      I 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        @IJoulz said in OpenCV linking undefined References:

        I am using the default 'Desktop Qt 6.6.0 MinGW 64-bit' kit.

        Why do you try to link against msvc libs then?

        LIBS += -L$$(OpenCV_DIR)/x64/vc16/lib/ -lopencv_world480

        You can not mix MSVC and MinGW c++ libraries.

        I Offline
        I Offline
        IJoulz
        wrote on last edited by
        #3

        @Christian-Ehrlicher Well, that explains it *facepalm*.
        I didnt catch that.

        1 Reply Last reply
        1
        • I IJoulz has marked this topic as solved on
        • JonBJ JonB referenced this topic on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved