dnl_anoj
dnl_anoj

Reputation: 371

Entry point not found on OpenCV dll with Qt 5.12

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

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

Upvotes: 3

Views: 419

Answers (1)

dnl_anoj
dnl_anoj

Reputation: 371

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!

Upvotes: 2

Related Questions