我嘗試了兩種使用opencv和qt創建器 的方法,第一個使用了Mingw,其中dll和.dll.a文件已經與opencv庫一起下載,我只是添加了對在.pro文件.dll.a文件如下使用Qt Creator設置OpenCV 2.4.2
INCLUDEPATH += D:\\OpenCV\\opencv\\build\\include
LIBS += D:\\OpenCV\\opencv\\build\\x64\\mingw\\lib\\libopencv_calib3d242.dll.a
LIBS += D:\\OpenCV\\opencv\\build\\x64\\mingw\\lib\\libopencv_contrib242.dll.a
LIBS += D:\\OpenCV\\opencv\\build\\x64\\mingw\\lib\\libopencv_core242.dll.a
LIBS += D:\\OpenCV\\opencv\\build\\x64\\mingw\\lib\\libopencv_features2d242.dll.a
我有一個簡單的代碼來測試的OpenCV:
#include <QtCore/QCoreApplication>
#include <opencv/cv.h>
using namespace cv;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Mat image;
return a.exec();
}
,但我得到了構建問題如下
C:\Users\Kato\Documents\QT projects\QtOpenCVYaRab\debug\main.o:-1: In function
~Mat': d:\OpenCV\opencv\build\include\opencv2\core\mat.hpp:278: error: undefined reference to
cv::fastFree(void*)' d:\OpenCV\opencv\build\include\opencv2\core\mat.hpp:367: error: undefined reference to `cv::Mat::deallocate()' :-1: error: collect2: ld returned 1 exit status
下面是一些編譯輸出:
Running build steps for project QtOpenCVYaRab...
Configuration unchanged, skipping qmake step.
Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/Kato/Documents/QT projects/QtOpenCVYaRab'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL
d:/OpenCV/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
debug/main.o:d:/OpenCV/opencv/build/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\QtOpenCVYaRab.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project QtOpenCVYaRab (target: Desktop)
When executing build step 'Make'
第二種方法是使用cmake編譯OpenCV庫的使用Visual Studio 2010來構建它,並在bin文件夾添加引用的文件,但我得到幾乎相同的建築問題。
請看看(OpenCV與其他圖形用戶界面)[http://support.microsoft.com/kb/2210937/opencv-with-other-gui-like-qt-or-wxwidgets-on-win32-vc/2212909 #2212909] – masad