QT + OpenCV + CMake + MSVC2019 Compatibility Issues
-
wrote on 9 Jan 2020, 09:29 last edited by
Hello all,
My Computer version is Windows 10, 64-bit Operating System
However I will be creating a 32 bit Widget Application with OpenCVI have the following versions installed in my computer
QT 5.12.6 (Everything under the Tab)
OpenCV 4.1.2 (Extracted from .exe file to a Folder)
CMake 3.16.2-win32-x86 (Should it be x64 as my PC is 64bit)?
MSVC2019 Version 16.3.7What are you thoughts? Will there be incompatibility issues between the versions when I try to use CMake to Interface OpenCV with MSVC2019?
If there are incompatibilities, what are the recommended versions to use?I tried the following tutorial (via link)
https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows_with_MSVC2017#CMakeI followed closely to their versions. However, there are errors when i use CMake to Configure QT with OpenCV (libraries aren't linked). Any reasons why?
-
Hello all,
My Computer version is Windows 10, 64-bit Operating System
However I will be creating a 32 bit Widget Application with OpenCVI have the following versions installed in my computer
QT 5.12.6 (Everything under the Tab)
OpenCV 4.1.2 (Extracted from .exe file to a Folder)
CMake 3.16.2-win32-x86 (Should it be x64 as my PC is 64bit)?
MSVC2019 Version 16.3.7What are you thoughts? Will there be incompatibility issues between the versions when I try to use CMake to Interface OpenCV with MSVC2019?
If there are incompatibilities, what are the recommended versions to use?I tried the following tutorial (via link)
https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows_with_MSVC2017#CMakeI followed closely to their versions. However, there are errors when i use CMake to Configure QT with OpenCV (libraries aren't linked). Any reasons why?
@Stevendragoes said in QT + OpenCV + CMake + MSVC2019 Compatibility Issues:
However, there are errors when i use CMake to Configure QT with OpenCV (libraries aren't linked). Any reasons why?
You should tell what errors exactly.
-
Hello all,
My Computer version is Windows 10, 64-bit Operating System
However I will be creating a 32 bit Widget Application with OpenCVI have the following versions installed in my computer
QT 5.12.6 (Everything under the Tab)
OpenCV 4.1.2 (Extracted from .exe file to a Folder)
CMake 3.16.2-win32-x86 (Should it be x64 as my PC is 64bit)?
MSVC2019 Version 16.3.7What are you thoughts? Will there be incompatibility issues between the versions when I try to use CMake to Interface OpenCV with MSVC2019?
If there are incompatibilities, what are the recommended versions to use?I tried the following tutorial (via link)
https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows_with_MSVC2017#CMakeI followed closely to their versions. However, there are errors when i use CMake to Configure QT with OpenCV (libraries aren't linked). Any reasons why?
@Stevendragoes said in QT + OpenCV + CMake + MSVC2019 Compatibility Issues:
OpenCV 4.1.2 (Extracted from .exe file to a Folder)
Which compiler was used to build this version of OpenCV 4.1.2? 32-bit or 64-bit?
QT 5.12.6 (Everything under the Tab)
You don't need everything under the tab. You only need the one version that uses the same compiler as the OpenCV build.
-
wrote on 10 Jan 2020, 01:05 last edited by
-
@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.
-
wrote on 10 Jan 2020, 01:39 last edited by
Hi @JKSH
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
-
Hi @JKSH
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
@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
-
wrote on 10 Jan 2020, 03:47 last edited by
@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 REBOOTAnd To all who are having issues installing OpenCV and QT, I followed this guide step by step
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.
-
@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 REBOOTAnd To all who are having issues installing OpenCV and QT, I followed this guide step by step
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.
@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.
-
@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 asneither 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.
-
wrote on 10 Jan 2020, 06:56 last edited by
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-directoryI tried their methods I couldn't solve the error.
Hence, I am reinstalling Microsoft Visual Studio 2017 now.
Meanwhile, it will be great if you don't mind clarifying my doubts?
- Microsoft Visual Studio Community 2017 is needed as a KIT to create Widgets Application under QT Creator?
- Compilers can be MSVC2019 when I press Manage and under Compilers.
- What about the Debuggers? should I use MinGW debugger? I need more information about them.
-
wrote on 10 Jan 2020, 07:18 last edited by
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.
-
wrote on 10 Jan 2020, 09:09 last edited by
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.
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 -
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.
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 thinkwrote on 17 May 2020, 13:49 last edited by@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
- 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
- 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 }
- 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