Building OpenCV for Qt
-
You have .a files haven't you ?
-
Well kind of. I have .dll.a files. And I have no idea how to make this work in Qt. The way it is shown in the example does not work for me, no matter what minor changes I try.
-
What example ?
-
The example/instructions on the Qt website on how to get opencv to work with Qt for Windows. On the bottom of the page they give an example code to test whether everything has been installed the properly. The instructions are on this page
-
Thanks for your help. I deleted my opencv-build directory, commented that line in CMake-file. Did CMake again, with IPP unchecked, ran make and make install again, but no luck. Still the same problem.
-
Maybe a silly question but, are you also using the Qt MinGW version to build that project ?
-
Do you have a static or dynamic build of OpenCV ?
-
@SGaist That's a good question. According to this YouTube video(I am sorry, but this was quite new for me so I used this as a source of information) at 7:46 it looks like a mix of a static Linux(.a) library and a dynamic Windows(.dll) library, since the files I got after making it have a .dll.a extension.
Anyway, I think I have found the solution for my problem. I will post it right away after this reaction :) Thanks SGaist for all your help!
-
So after a lot of searching the internet and getting very frustrated I found a solution that seems to work for me so far. I have no idea why this solves the problem and I think it is kind of strange but here is:
On Youtube I found a video where someone explained the exact same steps as described in the original tutorial published by Qt. The problem was the linking. CMake gave me some .dll.a files which I thoughtwas strange.
In this video that person got the excact same files as me (.dll.a). The problem was on how to link these files in the .pro-file.So here is the solution.
Instead of using this:LIBS += -LD:\opencv-build\install\x86\mingw\lib \ -lopencv_core320.dll \ -lopencv_highgui320.dll \ -lopencv_imgcodecs320.dll \ -lopencv_imgproc320.dll \ -lopencv_features2d320.dll \ -lopencv_calib3d320.dll
Use this:
LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_calib3d320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_core320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_features2d320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_flann320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_highgui320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_imgcodecs320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_imgproc320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_ml320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_objdetect320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_photo320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_shape320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_stitching320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_superres320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_video320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_videoio320.dll.a" LIBS += "C:\opencv-build\install\x86\mingw\lib\libopencv_videostab320.dll.a"
EDIT: This path "C:\opencv-build\install\x86\mingw\lib" also needs to be inserted in Path in System variables I have noticed in order to work.
Using those (longer unfortunately) lines of code, it did work for me. If anyone knows a simpler way of making this work I and presumably other people would appreciate it. Everyone thanks a lot for their help!-Martijn
-
Then why not:
LIBS += -LD:/opencv-build/lib \ -lopencv_core320 \ -lopencv_highgui320 \ # etc...
?