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. QT + OpenCV + CMake + MSVC2019 Compatibility Issues
Forum Updated to NodeBB v4.3 + New Features

QT + OpenCV + CMake + MSVC2019 Compatibility Issues

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 3.0k Views 2 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.
  • S Stevendragoes

    @jsulm I am sorry I didn't take the screenshot of the errors
    @JKSH Hello I used MSVC2017 to compile and build OpenCV4.1.2 in 32-bit Debug Mode
    Was it my choice of CMake Versions?

    I just installed everything over the night. Hopefully it works now.

    JKSHJ Offline
    JKSHJ Offline
    JKSH
    Moderators
    wrote on last edited by
    #5

    @Stevendragoes said in QT + OpenCV + CMake + MSVC2019 Compatibility Issues:

    I am sorry I didn't take the screenshot of the errors

    The error information will help you track down and solve the problem. if the error happens again, capture it.

    Hello I used MSVC2017 to compile and build OpenCV4.1.2 in 32-bit Debug Mode

    Then you need to install Qt for MSVC201x 32-bit. You don't need the others.

    Note: If you only have the Debug version of OpenCV, then you can only use the Debug version of Qt. You cannot use the Release version.

    Was it my choice of CMake Versions?

    I don't think the CMake version matters, as long as you are using a reasonably recent version.

    (Should it be x64 as my PC is 64bit)?

    No, that is fine. A 64-bit PC can run 32-bit applications.

    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

    1 Reply Last reply
    1
    • S Offline
      S Offline
      Stevendragoes
      wrote on last edited by
      #6

      Hi @JKSH
      76b1b14c-69a5-4f6a-a04e-3f3b0d2ac3a4-image.png

      This is the error I got. The directory is not found. any reasons why? I have installed QT5.12.6 and I used the Visual Studio 15 2017 to configure opencv libraries

      JKSHJ 1 Reply Last reply
      0
      • S Stevendragoes

        Hi @JKSH
        76b1b14c-69a5-4f6a-a04e-3f3b0d2ac3a4-image.png

        This is the error I got. The directory is not found. any reasons why? I have installed QT5.12.6 and I used the Visual Studio 15 2017 to configure opencv libraries

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #7

        @Stevendragoes said in QT + OpenCV + CMake + MSVC2019 Compatibility Issues:

        This is the error I got. The directory is not found. any reasons why?

        Read the error message carefully. It tells you how to fix it. ("Add the installation prefix...")

        Also, go through https://doc.qt.io/qt-5/cmake-get-started.html

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        1
        • S Offline
          S Offline
          Stevendragoes
          wrote on last edited by
          #8

          @JKSH Hello again.
          If I am not wrong, the guide was meant for an application if I were to use CMake as a compiler.
          However, I am using qmake as my compiler as I am building a GUI application. I just want CMake to Generate an OpenCV.sln with QT so that I can link the libraries of OpenCV to QT.
          And I think I have found the error.
          My best guess is that I didn't link the PATH in my environment variable and REBOOT

          And To all who are having issues installing OpenCV and QT, I followed this guide step by step

          https://github.com/MicrocontrollersAndMore/OpenCV_3_Windows_10_Installation_Tutorial/blob/master/Installation Cheat Sheet 4 - OpenCV 3 Compile From Source and Qt.pdf

          Now, My QT can type OpenCV languages like Mat, imshow, imread etc..

          My Current Working Specs are as follows
          QT 5.12.6 (MSVC2017 32bit)
          OpenCV 4.1.2 (Extracted from .exe file to a Folder)
          CMake 3.16.2-win32-x86
          MSVC2017 (if you have error of corecrt.h not found, follow the below link and install Universal CRT SDK)

          MSVC2019 wasn't supported in QT5.12.6 which is the latest LTS.

          JKSHJ 1 Reply Last reply
          0
          • S Stevendragoes

            @JKSH Hello again.
            If I am not wrong, the guide was meant for an application if I were to use CMake as a compiler.
            However, I am using qmake as my compiler as I am building a GUI application. I just want CMake to Generate an OpenCV.sln with QT so that I can link the libraries of OpenCV to QT.
            And I think I have found the error.
            My best guess is that I didn't link the PATH in my environment variable and REBOOT

            And To all who are having issues installing OpenCV and QT, I followed this guide step by step

            https://github.com/MicrocontrollersAndMore/OpenCV_3_Windows_10_Installation_Tutorial/blob/master/Installation Cheat Sheet 4 - OpenCV 3 Compile From Source and Qt.pdf

            Now, My QT can type OpenCV languages like Mat, imshow, imread etc..

            My Current Working Specs are as follows
            QT 5.12.6 (MSVC2017 32bit)
            OpenCV 4.1.2 (Extracted from .exe file to a Folder)
            CMake 3.16.2-win32-x86
            MSVC2017 (if you have error of corecrt.h not found, follow the below link and install Universal CRT SDK)

            MSVC2019 wasn't supported in QT5.12.6 which is the latest LTS.

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #9

            @Stevendragoes said in QT + OpenCV + CMake + MSVC2019 Compatibility Issues:

            And I think I have found the error.

            Great!

            If I am not wrong, the guide was meant for an application if I were to use CMake as a compiler.

            CMake and qmake are build tools. MSVC is your compiler.

            However, I am using qmake as my compiler as I am building a GUI application.

            You can use either CMake OR qmake to build GUI applications.

            My best guess is that I didn't link the PATH in my environment variable and REBOOT

            It is best to avoid putting libraries in the PATH because this might cause DLL Hell. Instead, configure your project to tell it where to find your libraries.

            For my 64-bit qmake project, I put this in my *.pro file:

            INCLUDEPATH += C:/tools/opencv/build/include/
            
            LIBS += \
                -LC:/tools/opencv/build/x64/vc15/lib \
                -LC:/tools/opencv/build/x64/vc15/bin
            
            CONFIG(debug, debug|release) {
                LIBS += -lopencv_world411d
            }
            CONFIG(release, debug|release) {
                LIBS += -lopencv_world411
            }
            

            MSVC2019 wasn't supported in QT5.12.6 which is the latest LTS.

            MSVC 2015, 2017, and 2019 are all compatible with each other. You can use Qt 5.12.6 for MSVC 2017 with the compiler from Visual Studio 2019.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            3
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #10

              @Stevendragoes said in QT + OpenCV + CMake + MSVC2019 Compatibility Issues:

              if I were to use CMake as a compiler.
              However, I am using qmake as my compiler as

              neither cmake nor qmake are compilers.

              MSVC2019 wasn't supported in QT5.12.6 which is the latest LTS.

              msvc2017 is compatible with msvc2019 so it was supported.

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

              1 Reply Last reply
              2
              • S Offline
                S Offline
                Stevendragoes
                wrote on last edited by
                #11

                Thanks @Christian-Ehrlicher and @JKSH

                Turns out I still faced an error it is something like this
                https://forum.qt.io/topic/65902/cannot-open-include-file-corecrt-h-no-such-file-or-directory

                I tried their methods I couldn't solve the error.
                Hence, I am reinstalling Microsoft Visual Studio 2017 now.
                42f76d8b-1084-4b5a-9d97-0804a89b9727-image.png

                Meanwhile, it will be great if you don't mind clarifying my doubts?

                1. Microsoft Visual Studio Community 2017 is needed as a KIT to create Widgets Application under QT Creator?
                2. Compilers can be MSVC2019 when I press Manage and under Compilers.
                3. What about the Debuggers? should I use MinGW debugger? I need more information about them.
                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Stevendragoes
                  wrote on last edited by
                  #12

                  Hello again @JKSH or everyone,

                  Is it better to use QT Creator to create my Application or Microsoft Visual Studio 2019?
                  Or should I use Microsoft Visual Studio 2017? I will use QT Widgets for my GUI application?

                  As I already installed Plugins for MSVC 2019. When I tried to create the GUI Application, it says that I need to specify the BUILD of QT. I already have QT 5.12.6 installed.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Stevendragoes
                    wrote on last edited by
                    #13

                    I have ended up using Microsoft Visual Studio 2017 to Build my Application with QT Plugin As I was unable to link the Windows Kit Header Files to QT Creator. The Results are As Follows.

                    d9be22b3-e0e1-4041-9f03-4a74dd264cc7-image.png

                    Then from the Project File Properties, I can link all the libraries of OpenCV to be incorporated to the project file.
                    Let me know what you guys think

                    D 1 Reply Last reply
                    0
                    • S Stevendragoes

                      I have ended up using Microsoft Visual Studio 2017 to Build my Application with QT Plugin As I was unable to link the Windows Kit Header Files to QT Creator. The Results are As Follows.

                      d9be22b3-e0e1-4041-9f03-4a74dd264cc7-image.png

                      Then from the Project File Properties, I can link all the libraries of OpenCV to be incorporated to the project file.
                      Let me know what you guys think

                      D Offline
                      D Offline
                      D.Maya
                      wrote on last edited by
                      #14

                      @Stevendragoes Hello Steven,

                      Let me help you how I build OpenCV-4.3.0 from source with MSVC2019 ver.16.5.4 and then how I added OpenCV to Qt Creator

                      1. After successful build and installation of OpenCV source binaries I have added to System Environment - System Variables Path the .dll files for Release and Debug separately.
                      C:\opencv-4.3.0\build_MSVC\bin\Release
                      C:\opencv-4.3.0\build_MSVC\bin\Debug
                      
                      1. Create a new project in Qt Creator and edit the .pro file as follows:
                      INCLUDEPATH += C:\opencv-4.3.0\build_MSVC\install\include
                      
                      LIBS += -LC:\opencv-4.3.0\build_MSVC\install\x64\vc16\lib
                      
                      CONFIG(debug, debug|release) {
                          LIBS += -lopencv_core430d -lopencv_highgui430d -lopencv_imgcodecs430d -lopencv_imgproc430d -lopencv_video430d -lopencv_videoio430d
                      }
                      CONFIG(release, debug|release) {
                          LIBS += -lopencv_core430 -lopencv_highgui430 -lopencv_imgcodecs430 -lopencv_imgproc430 -lopencv_video430 -lopencv_videoio430
                      }
                      
                      1. On the left of the left side bar in Qt Creator click on Projects.
                        Under the Build & Run go to Run section and check the Environment group on the right.
                        Base Environment for this configuration : System Environment
                        click on Details and check out the Path variable and make sure that the .dll paths for Release and Debug is there. If not press Edit and manually add the paths as stated in Step 1.

                      That's it. You can add any third party library the similar way.

                      Hope it helps.

                      D.Maya

                      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