Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Integrating OpenCV libraries in QtCreator on Windows
QtWS25 Last Chance

Integrating OpenCV libraries in QtCreator on Windows

Scheduled Pinned Locked Moved Installation and Deployment
14 Posts 2 Posters 21.2k 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.
  • B Offline
    B Offline
    Bogie
    wrote on last edited by
    #1

    Hi Guys,

    I have a certain problem concerning the integration of OpenCV libraries in Qt creator:
    I've downloaded the opencv-249.exe, extracted it and tried to include the libraries by adding to the .pro file the following:

    @ LIBS += "C:\OpenCV\opencv_bin\install\bin\.dll"
    LIBS += "C:\OpenCV\opencv_bin\install\lib\
    .dll*"@

    Unfortunaley I always got Linking errors like " unresolved extern symbol..."

    After that I tried to compile the libraries myself by creating a make-file with cmake adding the "WITH QT" option and compiling it with the mingw32-compiler.

    Unfortunaley I got errors during the compilation.

    After that I tried to compile an older version of OpenCV (I think 2.4.0) and it worked:)
    But if I try to include them in the following test program I always get the error

    bq. :-1: Error: LNK1104: Cannot open file "libopencv_highgui231d.lib"

    @#include "opencv2/opencv.hpp"

    using namespace std;

    int main (int argc, char *argv[]){

        cout << "Hello World!" << endl;
    
        cv::Mat mat;
        mat = cv::imread("BM_Logo.JPG");
        cvNamedWindow("hello");
        cv::imshow("hello",mat);
    
        cvWaitKey(0);
    
        return 0;
    

    }@

    Also I tried to add the libraries by clicking through the menu of qt, and I tried to write each library seperatly
    but still the error is the same.

    I hope there is anybody around here who can help me with this Problem because I am getting crazy around here

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You have to link to the lib files not the dlls. You should also try linking to only the libs your are using.

      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
      0
      • B Offline
        B Offline
        Bogie
        wrote on last edited by
        #3

        Hi:)

        thank you very much for fast answer. But I don't have .lib files in my own compiled version I only .dll and .dll.a.

        In the built version are some .lib files (although I think they are not for the mingw32-compiler I am using but for vc10)
        I tried to link them but I get the same error

        bq. :-1: Error: LNK1104: Cannot open file “libopencv_highgui231d.lib”

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then let's start at the beginning:
          What compiler do you want to use ? Doesn't the OpenCV pre-built package give you what you need ?

          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
          0
          • B Offline
            B Offline
            Bogie
            wrote on last edited by
            #5

            I want to use the mingw compiler, there is a folder in the pre-built package called mingw so I suppose this schould work, but it doesnt.

            There are only *dll and *ddl.a files where I get the same errors as above.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You should rather use something like

              @LIBS += -LC:/OpenCV/opencv_bin/install/mingw/whathever
              -lopencv_highgui231d
              -lopencv_core231d
              etc...
              @

              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
              0
              • B Offline
                B Offline
                Bogie
                wrote on last edited by
                #7

                Yeah thank you very much:) when I added these lines in the .pro file the project gets compiled.

                @LIBS += -LC:/OpenCV/opencv_bin/install/lib/ -llibopencv_core231d
                -llibopencv_highgui231d

                INCLUDEPATH += C:/OpenCV/opencv_bin/install/include
                DEPENDPATH += C:/OpenCV/opencv_bin/install/include
                @

                Unfortunaley after the compiling there is just showing up the console and nothing happends :(

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  No error message ?

                  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
                  0
                  • B Offline
                    B Offline
                    Bogie
                    wrote on last edited by
                    #9

                    no just the "qt_creator_stub.exe"

                    but this appears even when I uncomment the whole code

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @mat = cv::imread("BM_Logo.JPG");@

                      relative path, in that case you should either copy the image in the same folder as your application or give the absolute path to it.

                      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
                      0
                      • B Offline
                        B Offline
                        Bogie
                        wrote on last edited by
                        #11

                        No doesnt change anything.

                        The strange thing is, even the "Hello World" doesnt appear if I use at least one function of the cv library only when I uncomment these functions the "hello world" appears.

                        the output window says:

                        bq. return value = -1073741515

                        and also the debugger crashes immediatly

                        edit:

                        I also tried compiling the project with the console, but when I start the .exe it says:

                        bq. The programm cannot be started, because the ..highgui249.dll is missing on this computer. Reinstall the programm ...

                        When I copy the dlls of opencv in the folder with the executable it says

                        bq. The programm cannot be started, because the ..QtCore4.dll is missing on this computer. Reinstall the programm ...

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Looks like your OpenCV DLLs can't be found.

                          Go the run part of the Project panel, edit the PATH environment variable and add the path to the folder where the OpenCV dlls are located.

                          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
                          0
                          • B Offline
                            B Offline
                            Bogie
                            wrote on last edited by
                            #13

                            IT WORKS!!

                            Thank you very much:)

                            you definitely saved my day:)

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              You're welcome !

                              Since OpenCV is working now, please update the thread title prepending [solved] so other forum users may know solution has been found :)

                              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
                              0

                              • Login

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