在使用 Qt 5.12 的 OpenCV dll 上找不到入口点 [英] Entry point not found on OpenCV dll with Qt 5.12

查看:133
本文介绍了在使用 Qt 5.12 的 OpenCV dll 上找不到入口点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TLDR: 将 OpenCV 与 QT MingW 链接会使应用程序在 Debug 中崩溃但不会发布.

我正在尝试在基于 Qt 的大型多操作系统项目中使用 OpenCV.我已经轻松地为 Mac 和 Linux 构建了 OpenCV,但我很难在 Windows 上使用它.

环境:

Qt 5.12.2 MinGW

MinGW 8.1.0 64 位

OpenCV 基本上是 4.1.0 以后的所有版本

CMake 3.19

我的尝试

  • 我首先尝试按照他的链接从源代码构建 OpenCV

    我已经看到这可能是 TBB 问题,所以我尝试使用 MSys 的不同版本但没有成功.

    我尝试从 Qt 更改 PATH 变量以用于构建和运行,但没有成功.

    我的 .pri 中的包含和 Libs 使用如下(它们都是在构建过程中找到的)

    INCLUDEPATH += -I $$PWD/../../ext/OpenCV/include/opencv4DEPENDPATH += -$$PWD/../../ext/OpenCV/include/opencv4LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_imgproc430LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_core430LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_dnn430LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_imgcodecs430LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_highgui430

    解决方案

    好吧,我终于设法让它工作了!正如我在我的问题中所说的,当 TBB 版本不正确时,有时会发生此错误,所以这就是我所做的:

    • 使用此存储库手动构建 TBB:https://github.com/wjakob/tbb 包含官方存储库的基于 CMake 的构建系统:https://github.com/oneapi-src/oneTBB

    • 使用您稍后将在应用程序中使用的编译器构建所需版本的 OpenCV:

      • 取消选中BUILD_TBB",选中WITH_TBB"并指向之前构建的 TBB 库并包含.
      • 添加您需要的标志(例如 OPENCV_ENABLE_ALLOCATOR_STATS=OFF)并构建它.
    • 最后从path/to/opencv-build/bin"而不是path/to/opencv-build/install/bin"添加库(也许这是我们应该一直做的,但我不是当然),它对我有用!

    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
    

    解决方案

    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!

    这篇关于在使用 Qt 5.12 的 OpenCV dll 上找不到入口点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆