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. Problems setting up OpenCV in Qt
Forum Updated to NodeBB v4.3 + New Features

Problems setting up OpenCV in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 2.1k Views 1 Watching
  • 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.
  • E Offline
    E Offline
    Edkahe
    wrote on 23 Sept 2016, 18:13 last edited by
    #1

    Hi,

    I'm using OpenCV since a few days within the scope of an internship. To get some extra exercise I wanted to set it up on my private laptop (Win10 x64). Therefore I installed 5.7 and downloaded OpenCV 2.4.13. From the command line, I executed the command "setx -m OPENCV_DIR C:\opencv\build\x64\vc11". This is how my *.pro file looks like:

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = TEST
    TEMPLATE = app

    INCLUDEPATH += C:/opencv/build/include
    LIBS += C:/opencv/build/x64/vc11/bin/opencv_core2413d.dll
    LIBS += C:/opencv/build/x64/vc11/bin/opencv_highgui2413d.dll
    LIBS += C:/opencv/build/x64/vc11/bin/opencv_imgproc2413d.dll
    LIBS += C:/opencv/build/x64/vc11/lib

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    I tried to run a really basic example with cv::imread and cv::imshow but if I build the project it tells me:

    "file not recognized: File format not recognized opencv_core2413d.dll".

    I also tried some other configurations from other forums but the problem stays the same...
    I never had to set up libraries or similar before so that my knowledge is really bad. Please tell me if I missed some important information.

    Thanks for your help in advance!

    M 1 Reply Last reply 23 Sept 2016, 18:31
    0
    • V Offline
      V Offline
      VRonin
      wrote on 23 Sept 2016, 18:29 last edited by VRonin
      #2

      You do not link to the dll but to the .lib on windows

      replace

      LIBS += C:/opencv/build/x64/vc11/bin/opencv_core2413d.dll
      LIBS += C:/opencv/build/x64/vc11/bin/opencv_highgui2413d.dll
      LIBS += C:/opencv/build/x64/vc11/bin/opencv_imgproc2413d.dll
      LIBS += C:/opencv/build/x64/vc11/lib
      

      with

      LIBS += -LC:/opencv/build/x64/vc11/lib -lopencv_core2413d -lopencv_highgui2413d -lopencv_imgproc2413d
      

      or, using your environmental variable:

      LIBS += -L$(OPENCV_DIR)/lib -lopencv_core2413d -lopencv_highgui2413d -lopencv_imgproc2413d
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • E Edkahe
        23 Sept 2016, 18:13

        Hi,

        I'm using OpenCV since a few days within the scope of an internship. To get some extra exercise I wanted to set it up on my private laptop (Win10 x64). Therefore I installed 5.7 and downloaded OpenCV 2.4.13. From the command line, I executed the command "setx -m OPENCV_DIR C:\opencv\build\x64\vc11". This is how my *.pro file looks like:

        QT += core gui

        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

        TARGET = TEST
        TEMPLATE = app

        INCLUDEPATH += C:/opencv/build/include
        LIBS += C:/opencv/build/x64/vc11/bin/opencv_core2413d.dll
        LIBS += C:/opencv/build/x64/vc11/bin/opencv_highgui2413d.dll
        LIBS += C:/opencv/build/x64/vc11/bin/opencv_imgproc2413d.dll
        LIBS += C:/opencv/build/x64/vc11/lib

        SOURCES += main.cpp
        mainwindow.cpp

        HEADERS += mainwindow.h

        FORMS += mainwindow.ui

        I tried to run a really basic example with cv::imread and cv::imshow but if I build the project it tells me:

        "file not recognized: File format not recognized opencv_core2413d.dll".

        I also tried some other configurations from other forums but the problem stays the same...
        I never had to set up libraries or similar before so that my knowledge is really bad. Please tell me if I missed some important information.

        Thanks for your help in advance!

        M Offline
        M Offline
        mchinand
        wrote on 23 Sept 2016, 18:31 last edited by
        #3

        Are you using the same compiler that you used to build the openCV library? Which compiler? From the dll file names, it looks like you are using a debug build of openCV; does that match the build type of your test program (debug/release)?

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Edkahe
          wrote on 23 Sept 2016, 19:03 last edited by
          #4

          Ok I replaced the LIBS section, now this occurs:

          0_1474657029718_upload-22d8238a-3582-4da6-bbce-8cc9a1657961

          (I hope the screenshot is attached)
          For Qt, I use MinGW GCC. It was already included when downloading the Qt package.
          How do I build the openCV library? I just followed some instructions from the net. But I think it still fails because of my missing knowledge.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 23 Sept 2016, 20:35 last edited by
            #5

            Hi and welcome to devnet,

            From the looks of it, you are trying to link a Visual Studio built OpenCV against a MinGW built Qt. There at least two problems here:

            1. From the path of your OpenCV build, it's a 64bit version and the MinGW Qt package is 32bit
            2. You are trying to link libraries built with two different compilers. You can't mix and match like that. The compilers are not compatible one with the other and that's not limited to Visual Studio VS MinGW, it's also the case between different version of Visual Studio.

            One thing you can do is build OpenCV with the MinGW version provided with Qt.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2

            1/5

            23 Sept 2016, 18:13

            • Login

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