gpt4 book ai didi

qt - 需要帮助在 Windows 上的 Qt Creator 中链接静态 OpenCV 库

转载 作者:太空宇宙 更新时间:2023-11-03 21:00:42 26 4
gpt4 key购买 nike

我在链接动态 opencv 库时没有问题,但我想改用静态库,所以我重建了 OpenCV 2.3,并取消选中“构建共享库”选项。我将以下内容放在我的 .pro 文件中

LIBS += "C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_calib3d231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_contrib231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_core231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_features2d231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_flann231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_gpu231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_imgproc231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_legacy231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_ml231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_objdetect231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_ts231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_video231.a"

INCLUDEPATH += "C:\Program Files\openCV_static\opencv\build\install\include"
INCLUDEPATH += "C:\Program Files\openCV_static\opencv\build\install\include\opencv"

这与我之前使用动态库时的情况非常相似,只是 .a 文件实际上以 .dll .a 结尾,并且我将 dll(而不是 dll.a 文件)放在 qt 程序的输出目录(以便程序可以找到它们并运行)。现在重点是我不需要那些 dll,所以它们不再在我程序的输出目录中(实际上它们不是用 OpenCV 构建的)。但是当我尝试构建我的程序时出现这些错误:

C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN17CvVideoWriter_VFW5closeEv+0x13): undefined reference to `AVIStreamRelease@4'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN17CvVideoWriter_VFW5closeEv+0x25): undefined reference to `AVIStreamRelease@4'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN17CvVideoWriter_VFW5closeEv+0x37): undefined reference to `AVIFileRelease@4'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN16CvCaptureCAM_VFW4openEi+0x6c): undefined reference to `capGetDriverDescriptionA@20'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN16CvCaptureCAM_VFW4openEi+0xb7): undefined reference to `capCreateCaptureWindowA@32'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN16CvCaptureAVI_VFW9grabFrameEv+0x29): undefined reference to `AVIStreamGetFrame@8'
.
.
.
.
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(grfmt_jpeg2000.obj):grfmt_jpeg2000.cpp:(.text$_ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x17b): undefined reference to `jas_stream_close'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(grfmt_jpeg2000.obj):grfmt_jpeg2000.cpp:(.text.startup._GLOBAL__sub_I_C__Program_Files_openCV_static_opencv_modules_highgui_src_grfmt_jpeg2000.cpp+0x4): undefined reference to `jas_init'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [release\trusion.exe] Error 1
mingw32-make.exe: *** [release] Error 2
23:21:10: The process "C:\MinGW\bin\mingw32-make.exe" exited with code 2.
Error while building project trusion (target: Desktop)
When executing build step 'Make'

我正在使用 MinGW。使用用于构建 opencv 的相同工具链编译项目。如上所述,使用动态库。不适用于静态库。

最佳答案

您似乎缺少 Jasper 依赖项。Windows 上的 OpenCV 使用预构建的 libjasper 库 (lib/libjasper*),尝试将它们添加到 LIBS

对于 'undefined reference to AVIStreamRelease@4'错误,尝试链接 vfw32.lib 或 MSVFW32.dll

关于qt - 需要帮助在 Windows 上的 Qt Creator 中链接静态 OpenCV 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9630592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com