开心123 发表于 2015-5-11 14:24:27

Qt Creator+MinGW+OpenCV2.3.1 开发环境搭建(windows 7 系统)

  毕设需要的windows下开发环境。QT+opncv+openGL(QTSDK已经包含)
  接下来还要在RHEL6.2下配置,还要配置交叉编译,好头疼,一步步来吧,看来加个群多问问还是有好处的。
  1.必备软件:
  Qt SDK for Open Source C++ development on Windows:http://qt.nokia.com/downloads/sdk-windows-cpp-offline
  QT开发所必需的全部资源都在这里了
  OpenCV-2.3.1-win-superpack:http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/
  目前最新的OpenCV版本,里面有源码和编译好的各版本的DLL和LIB,以防万一,还是自己编译吧
  cmake-2.8.5-win32-x86:http://www.cmake.org/cmake/resources/software.html
  编译OpenCV要用到。
  
  2.安装软件
  安装Qt SDK,第一次选择default安装,装了很久,装完后用Qt Creator打开QT 测试程序,会出现目标设置的对话框,发现只有塞班设备可选,我本来是要做桌面开发的,找不到桌面选项。自己也不会调整。果断卸载重装,选择custom,把塞班开发相关的选项去掉,这样安装也会快很多,装完后用Qt Creator再次打开QT 测试程序。出现:

  选择桌面(选择Qt模拟器也能运行,出来的是个塞班手机模拟器),即可运行测试程序。
  不需要什么特别的配置,因为安装SDK的时候Qt Creator已经配置好了。如下图,有两个编译器可以选择,MSVC2008和MinGW4.4

  这里选择MinGW4.4,因为下面的OpenCV使用MinGW4.4编译。 把 “/mingw/bin” 添加到环境变量PATH中。

  安装OpenCV,将OpenCV-2.3.1-win-superpack.exe解压至全英文不带空格的路径里面()。目录下build文件夹里应该是编译好的东西,暂时不用,其他是源码自己编译呗。
  安装cmake-2.8.5-win32-x86.exe。生成makefile用的
  
  3.编译OpenCV
  然后下面的步骤参考了别的文章:
  Steps to build OpenCV with Qt Creator and MinGW
1. Run CMake GUI.
  2. Set the source code: “”
  3. Set where to build binaries to: “”. Example: E:\OpenCV-2.3.1\MinGW
  4. Press Configure
  5. Let CMake create the new folder.
  6. Specify the generator: MinGW Makefiles.
  7. Select “Specify Native Compilers” and click Next.
  8. For C set: “/mingw/bin/gcc.exe”
  9. For C++ set: “/mingw/bin/g++.exe”
  10. Click Finish
  11. In the configuration screen type in “DEBUG” (or “RELEASE” if you want to build a release version) for CMAKE_BUILD_TYPE. Check BUILD_EXAMPLES if you want. Check WITH_QT .Uncheck WITH_QT.
  12. Click configure again.
  13. The configure screen will make you specify the qmake path. It is in the Qt directory: “/qt/bin/qmake.exe”
  14. Click configure again. Click generate. Close CMake.
  15. Go to the command prompt and go to the folder where you built your binaries (command: cd ) and type “mingw32-make” and hit enter (this might take some time).
  16. Then type “mingw32-make install” and hit enter again




  等待编译,结束后需要的东西都在install文件夹里面了。把\install\bin添加到环境变量PATH里面吧。例如E:\OpenCV-2.3.1\MinGW\install\bin
  重新启动。没重启没添加这个环境变量前,Qt Creator配置好后运行OpenCV -QT测试程序会出错。
  4.Qt Creator配置OpenCV
  只需要修改.pro文件,添加include和lib。例如

INCLUDEPATH+=E:\OpenCV-2.3.1\MinGW\install\include
INCLUDEPATH+=E:\OpenCV-2.3.1\MinGW\install\include\opencv
LIBS+=E:\OpenCV-2.3.1\MinGW\install\lib\libopencv_core231d.dll.a
LIBS+=E:\OpenCV-2.3.1\MinGW\install\lib\libopencv_highgui231d.dll.a
LIBS+=E:\OpenCV-2.3.1\MinGW\install\lib\libopencv_imgproc231d.dll.a
  然后下面就没什么问题了吧。运行下测试程序吧:
  程序在这里OpenCV_Example:http://vdisk.weibo.com/s/y6Kv

  
  
  
  
  
  
  
  
  
页: [1]
查看完整版本: Qt Creator+MinGW+OpenCV2.3.1 开发环境搭建(windows 7 系统)