zoukankan      html  css  js  c++  java
  • Win7下qt5.3.1+opencv2.4.9编译环境的搭建(好多 Opencv2.4.9源码分析的博客)

     

    到官网下载qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe文件,执行该文件,选择默认安装即可实现QT的安装(安装在C盘的根目录下),该文件封装好了Qt libraries、Qt Creator,其中Qt Creator为3.1.2版本。

     

    到官网http://opencv.org/downloads.html下载OpenCV for Windows2.4.9版本——opencv-2.4.9.exe。执行该文件,把它解压到适当的目录下即可,我是把它放到了c盘的根目录下,即c:opencv。

     

    http://www.cmake.org/cmake/resources/software.html下载cmake-3.0.1-win32-x86.exe文件。安装cmake,安装在C:CMake目录下。

     

    设置系统的环境变量,即把C:QtQt5.3.1ToolsMinGWin加入系统的Path环境变量中,因为在CMake编译过程中会用到该目录下的库。

     

    在桌面上点击CMake(cmake-gui)图标,执行CMake,在Where is the source code栏和Where to build thebinaries栏中分别C:/opencv/soureces为opencv和C:/opencv/MinGW。C:/opencv/MinGW为编译后库文件所存放的目录,需要自己创建该目录。然后点击configure按钮,打开新的窗口,在Specify the generator for this project下选择MinGW Makefiles,然后选择Specify native compilers,点击Next按钮,打开新的窗口,在C一栏中填写C:/Qt/Qt5.3.1/Tools/mingw482_32/bin/gcc.exe,在C++一栏中填写C:/Qt/Qt5.3.1/Tools/mingw482_32/bin/g++.exe,Fortran不填写。然后点击Finish按钮,开始配置,这时会出现如下的类似错误提示:

    CMake Error: CMake was unable to find abuild program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different buildtool.

    CMake Error: CMake was unable to find abuild program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different buildtool.

    CMake Error: Error required internal CMakevariable not set, cmake may be not be built correctly.

    Missing variable is:

    CMAKE_CXX_COMPILER_ENV_VAR

    CMake Error: Could not find cmake modulefile: C:/opencv/MinGW/CMakeFiles/3.0.1/CMakeCXXCompiler.cmake

    CMake Error: Error required internal CMakevariable not set, cmake may be not be built correctly.

    Missing variable is:

    CMAKE_C_COMPILER_ENV_VAR

    CMake Error: Could not find cmake modulefile: C:/opencv/MinGW/CMakeFiles/3.0.1/CMakeCCompiler.cmake

    Configuring incomplete, errors occurred!

    找到Name为CMAKE_MAKE_PROGRAM的一项,把它的Value填写为C:/Qt/Qt5.3.1/Tools/mingw482_32/bin/mingw32-make.exe即可。再次点击Configure,这时不会提示任何错误,表明配置成功。

    我们还需要把QT加上,找到WITH,把它下面的WITH_QT和WITH_OPENGL选上,再次Configure。这时会出现类似下面的错误提示:

    CMake Error atC:/CMake/share/cmake-3.0/Modules/FindQt4.cmake:1316 (message):

     Found unsuitable Qt version "" from NOTFOUND, this coderequires Qt 4.x

    Call Stack (most recent call first):

     cmake/OpenCVFindLibsGUI.cmake:34 (find_package)

     CMakeLists.txt:466 (include)

    找到QT_QMAKE_EXECUTABLE,它的值填写为:C:/Qt/Qt5.3.1/5.3/mingw482_32/bin/qmake.exe

    找到QT_MKSPECS_DIR,它的值填写为:C:/Qt/Qt5.3.1/5.3/mingw482_32/mkspecs

    找到QT_QTCORE_LIBRARY_DEBUG,它的值填写为:C:/Qt/Qt5.3.1/5.3/mingw482_32/bin/Qt5Cored.dll

    找到QT_QTCORE_LIBRARY_RELEASE,它的值填写为C:/Qt/Qt5.3.1/5.3/mingw482_32/bin/Qt5Core.dll

    找到QT_QTCORE_INCLUDE_DIR,它的值填写为C:/Qt/Qt5.3.1/5.3/mingw482_32/include/QtCore/5.3.1/QtCore

    再次点击Configure,这时会出现类似下面的错误提示:

    CMake Error atC:/CMake/share/cmake-3.0/Modules/FindQt4.cmake:1316 (message):

     Found unsuitable Qt version "5.3.1" from

     C:/Qt/Qt5.3.1/5.3/mingw482_32/bin/qmake.exe, this code requires Qt 4.x

    Call Stack (most recent call first):

     cmake/OpenCVFindLibsGUI.cmake:34 (find_package)

     CMakeLists.txt:466 (include)

    Ungrouped Entries下找到Qt5Concurrent_DIR,Qt5Core_DIR,Qt5Gui_DIR,Qt5Test_DIR,Qt5Widgets_DIR,Qt5OpenGL_DIR,它们的Value分别填写为:

    C:/Qt/Qt5.3.1/5.3/mingw482_32/lib/cmake/Qt5Concurrent

    C:/Qt/Qt5.3.1/5.3/mingw482_32/lib/cmake/Qt5Core

    C:/Qt/Qt5.3.1/5.3/mingw482_32/lib/cmake/Qt5Gui

    C:/Qt/Qt5.3.1/5.3/mingw482_32/lib/cmake/Qt5Test

    C:/Qt/Qt5.3.1/5.3/mingw482_32/lib/cmake/Qt5Widgets

    C:/Qt/Qt5.3.1/5.3/mingw482_32/lib/cmake/Qt5OpenGL

    再次Configure,这时配置完成,不会出现任何错误提示。虽然会有许多警告,如This warning is for project developers. Use -Wno-dev to suppress it.,但不用去管,按Generate。Generate完成后,关闭CMake窗口。

    打开系统的命令终端,进入C:opencvMinGW目录,执行mingw32-make命令,这需要一段时间,该命令执行完后,再执行mingw32-make install命令。这样可用于Qt的opencv库文件就生成了。

    再次添加系统的Path环境变量,内容为:c:QtQt5.3.15.3mingw482_32in;c:opencvMinGWin。

    以后我们用Qt Creator编译opencv的时候,在创建一个新工程后,还需要在该工程的工程文件.pro文件内添加下列语句:

    INCLUDEPATH+=c:opencvuildincludeopencv

    c:opencvuildincludeopencv2

           c:opencvuildinclude

     

    LIBS+=c:opencvMinGWliblibopencv_calib3d249.dll.a

      c:opencvMinGWliblibopencv_contrib249.dll.a

      c:opencvMinGWliblibopencv_core249.dll.a

      c:opencvMinGWliblibopencv_features2d249.dll.a

      c:opencvMinGWliblibopencv_flann249.dll.a

      c:opencvMinGWliblibopencv_gpu249.dll.a

      c:opencvMinGWliblibopencv_highgui249.dll.a

      c:opencvMinGWliblibopencv_imgproc249.dll.a

      c:opencvMinGWliblibopencv_legacy249.dll.a

      c:opencvMinGWliblibopencv_ml249.dll.a

      c:opencvMinGWliblibopencv_objdetect249.dll.a

      c:opencvMinGWliblibopencv_video249.dll.a

     

    完成!

    http://blog.csdn.net/zhaocj/article/details/38944037

  • 相关阅读:
    HDU 1069 Monkey and Banana
    HDU 1029 Ignatius and the Princess IV
    HDU 1024 Max Sum Plus Plus
    Gym100923H Por Costel and the Match
    Codeforces 682C Alyona and the Tree
    Codeforces 449B Jzzhu and Cities
    Codeforces (ccpc-wannafly camp day2) L. Por Costel and the Semipalindromes
    Codeforces 598D (ccpc-wannafly camp day1) Igor In the Museum
    Codeforces 1167c(ccpc wannafly camp day1) News Distribution 并查集模板
    快乐数问题
  • 原文地址:https://www.cnblogs.com/findumars/p/5625550.html
Copyright © 2011-2022 走看看