Need help linking OpenCV static libraries in Qt Creator on Windows

I have no problem linking opencv dynamic libraries, but instead I want to use static libraries, so I restored OpenCV 2.3 with the option "collect shared libraries". I put the following in my .pro file

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" 

This is very similar to what it used to be when I used dynamic libraries, except that the .a files actually ended .dll.a and I put the dll (and not the dll.a files) in the qt program (so the program could find and run them). Now the thing is that I do not need these DLLs, so they are no longer in my output directory of the program (in fact, they were not built with OpenCV). But I get these errors when I try to create my program:

 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' 

I am using MinGW. Compiling a project using the same toolchain as creating opencv. Worked with dynamic libraries, as mentioned above. It does not work with static libraries.

+4
source share
1 answer

It seems you lack Jasper's addiction. OpenCV on Windows uses the pre-created libjasper library (lib / libjasper *), try adding them to LIBS

For the error 'undefined reference to AVIStreamRelease@4 ' try to establish a connection with vfw32.lib or MSVFW32.dll

+1
source

Source: https://habr.com/ru/post/1400533/


All Articles