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
QtWS25 Last Chance

OpenCV linking undefined References

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.0k 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 15 Nov 2023, 14:43 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.

    C 1 Reply Last reply 15 Nov 2023, 15:32
    0
    • I IJoulz
      15 Nov 2023, 14:43

      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.

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 15 Nov 2023, 15:32 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 15 Nov 2023, 16:01
      2
      • C Christian Ehrlicher
        15 Nov 2023, 15:32

        @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 15 Nov 2023, 16:01 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 15 Nov 2023, 16:01
        • J JonB referenced this topic on 28 Dec 2023, 18:58

        1/3

        15 Nov 2023, 14:43

        • Login

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