Entry point not found on OpenCV dll with Qt 5.12

Viewed 197

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:

enter image description here

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
1 Answers

Okay so I finally managed to get it work! As I said in my question this error happens sometimes when the TBB version is not correct so here's what I did:

  • Build manually TBB with this repository: https://github.com/wjakob/tbb which contains a CMake-based build system of the official repository : https://github.com/oneapi-src/oneTBB

  • Build OpenCV with the version needed using the compilers you will use later in your application:

    • Uncheck 'BUILD_TBB', check 'WITH_TBB' and point to the previously built TBB libraries and include.
    • Add the flags you need ( OPENCV_ENABLE_ALLOCATOR_STATS=OFF for instance ) and build it.
  • Finally add the libraries from 'path/to/opencv-build/bin' instead of 'path/to/opencv-build/install/bin' (maybe that's what we should always do but I wasn't sure) and it worked for me!

Related