TLDR: Linking OpenCV with QT MingW makes application crash in Debug but not release.
I am trying to use OpenCV in a large multi OS project based on Qt. I have easily managed to build OpenCV for Mac and Linux but I am very much struggling to use it on Windows.
Environment:
Qt 5.12.2 MinGW
MinGW 8.1.0 64bit
OpenCV basically all versions since 4.1.0
CMake 3.19
What I tried
I first tried to build OpenCV from source following his link https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows but had some issues running the application in Debug such as Entry Point not Found in opencv Library (exact error below)
I lately used prebuilt packages from MSys2 using its pacman and tried version 4.2 to 4.5 without real success. I managed a couple of time to link the OpenCV libraries from the installation path of msys (C:\msys64\mingw64\bin) and with this path in the environment PATH I was able to launch the application using the .exe generated by Qt. However once I dragged the needed libraries into our third party libraries folder for deployment the application can't start anymore in Debug (with Qt nor with the .exe).
I tried in Release mode and everything works fine
Now everytime I run the application in Debug with Qt the program crash immediately without even entering the main. I have the following error when I use the .exe:
I have seen that it could be a TBB issue so I tried using a different version from MSys without success.
I tried to change the PATH variables from Qt for the Build and the Run without success.
My includes and Libs in my .pri are used as follow (they are all found during the build)
INCLUDEPATH += -I $$PWD/../../ext/OpenCV/include/opencv4
DEPENDPATH += -$$PWD/../../ext/OpenCV/include/opencv4
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_imgproc430
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_core430
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_dnn430
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_imgcodecs430
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_highgui430
