win7+Qt+OpenCV安装攻略

为了让桌面背景炫一点,灵活一点,升级了home basic版到ultimate版,有几个发现

1。gnome在win7下也有主题可以用,但是很难看,和fedora18下的gnome完全不是一个味道

2。升级之后系统path中的内容被清除,直接导致一些程序无法运行:

1)cmd下的ping和ipconfig命令失效,PATH中加入;%SystemRoot%\system32修复

2)我的Qt与OpenCV失效,Qt导入图片的基本操作都not work了!

为了用Qt+OpenCV所以重装了Qt,Cmake,OpenCV 并且找了“Qt5+OpenCV2.4.3在Cmake时候说QtCore找不到的问题”的解决方法。高手请无视,小白仔细看

软件版本:

Qt:qt-windows-opensource-5.0.1-mingw47_32-x86-offline.exe(其他的opensource版本也可以)

OpenCV:2.4.3(不是for windows的安装版,因为是要自己编译OpenCV源代码供Qt使用,而Qt使用MinGW)

Cmake:2.8.11(安装时要选“添加到系统路径中”)

我的几个路径:

Qt:    C:\Qt

OpenCV:   C:\software\opencv

OpenCV解压路径:   C:\software\opencv\buildForMinGW(双击OpenCV就可以解压)

添加三个环境变量:

C:\Qt\Qt5.0.1\5.0.1\mingw47_32\bin

C:\Qt\Qt5.0.1\Tools\MinGW\bin(后面make和make install时用到mingw32.exe)

C:\software\opencv\buildForMinGW\install\bin (不加此路径则程序运行时报错说libopencv_core.dll找不到等)

以上做好之后,不必重启电脑,直接运行Cmake-gui.exe即可

Cmake中选择源路径与目标路径,我的是C:/software/opencv和C:/software/opencv/buildForMinGW

然后,选择MinGW模式,specify native compilers(第二个选项),然后对于C和C++分别设定,我的是C:\Qt\Qt5.0.1\Tools\MinGW\bin\gcc.exe和C:\Qt\Qt5.0.1\Tools\MinGW\bin\g++.exe 确定后点左下方“configure”,会有很多项是红色的,这正常。

把WITH_QT勾选上,再configure一次,会报错说QtCore找不到的问题,例如:

CMake Warning at C:/software/CMake 2.8/share/cmake-2.8/Modules/FindQt4.cmake:615 (message): C:/software/qt/5.0.1/mingw47_32/bin/qmake.exe reported QT_INSTALL_LIBS as "C:/software/qt/5.0.1/mingw47_32/lib" but QtCore could not be found there. Qt is NOT installed correctly for the target build environment. Call Stack (most recent call first):
cmake/OpenCVFindLibsGUI.cmake:8 (find_package) CMakeLists.txt:377 (include)

此时勾选“Group”和“Advance”(在两个路径下面),展开Qt一项,找到 QT_QTCORE_LIBRARY_DEBUG进行设定,我的设定为C:/Qt/Qt5.0.1/5.0.1/mingw47_32/bin/Qt5Cored.dll然后configure,这次都是黑色的字了,说明没问题了,然后generate,完毕后关闭cmake

(我在这里找到的解答http://stackoverflow.com/questions/14919186/qt-creator-5-0-1-with-opencv-2-3-4-on-windows

到这里还没结束,还需要在cmd中进入编译好的目录下make和make install,我的:


cd C:\software\opencv\buildForMinGW

mingw32-make

mingw32-make install 

 

新建工程的时候在pro文件中添加

INCLUDEPATH+=C:/software/opencv/buildForMinGW/install/include\
C:/software/opencv/buildForMinGW/install/include/opencv\
C:/software/opencv/buildForMinGW/install/include/opencv2\


LIBS+=C:/software/opencv/buildForMinGW/install/lib/libopencv_calib3d243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_contrib243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_core243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_features2d243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_flann243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_gpu243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_highgui243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_imgproc243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_legacy243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_ml243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_nonfree243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_objdetect243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_photo243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_stitching243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_ts243.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_video243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_videostab243.dll.a
posted @ 2013-05-30 22:27  ChrisZZ  阅读(2309)  评论(0编辑  收藏  举报