2012-03-09 88 views
4

我沒有問題鏈接動態opencv庫,但我想要使用靜態庫,所以我重新選擇了「生成共享庫」選項未選中的OpenCV 2.3。我把我的.pro文件以下需要幫助鏈接在Windows上的Qt Creator中的靜態OpenCV庫

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" 

這是非常相似,我收到的時候我用的是動態庫,除了在.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 `[email protected]' 
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 `[email protected]' 
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 `[email protected]' 
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 `[email protected]' 
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 `[email protected]' 
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 `[email protected]' 
. 
. 
. 
. 
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的相同工具鏈編譯該項目。如上所述,使用動態庫。不適用於靜態庫。

+0

只是一個問題:如何做你設法用Qt支持構建opencv?我的構建不成功,因爲它需要一個名爲'qconfig.h'的文件,這個文件沒有伴隨我的Qt 4.6.3下載。你使用了哪個版本? – vsz 2012-04-07 16:22:06

+0

@vsz對於遲到感到抱歉。我沒有試圖用qt支持構建opencv。我只是將opencv庫導入到我正在編寫的qt程序中。 – jzepeda 2012-04-18 02:48:28

回答

1

看來你錯過了Jasper的依賴。 OpenCV的Windows上使用預建libjasper庫(LIB/libjasper *),試圖將其添加到庫

對於'undefined reference to [email protected]'錯誤,請嘗試將針對vfw32.lib或MSVFW32.dll

+0

謝謝,這似乎是冰山一角。之後,我還必須添加libs jpeg,tiff和png。現在我收到錯誤,比如'\ libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp :(。text $ _ZN17CvVideoWriter_VFW5closeEv + 0x13):未定義的AVIStreamRelease @ 4引用vfw相關的錯誤是我的web serches告訴我的,但我以前會如何解決它們? – jzepeda 2012-03-12 02:02:57

+0

我認爲你需要添加vfw庫。見編輯的答案。 – Masci 2012-03-12 09:31:24

+0

非常感謝!它做到了..我與Vfw32.lib鏈接。我必須先下載Windows 7 SDK。 – jzepeda 2012-03-12 18:00:36