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已經配置好了。如下圖,有兩個編譯器可以選擇MSVC2008MinGW4.4

這里選擇MinGW4.4,因為下面的OpenCV使用MinGW4.4編譯。 把 “<Qt_directory>/mingw/bin” 添加到環境變量PATH中。

安裝OpenCV,將OpenCV-2.3.1-win-superpack.exe解壓至全英文不帶空格的路徑里面(<OpenCV_directory>)。目錄下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: “<OpenCV_directory>”

3. Set where to build binaries to: “<build_directory>”. 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: “<Qt_directory>/mingw/bin/gcc.exe”

9. For C++ set: “<Qt_directory>/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_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 <build_directory>) and type “mingw32-make” and hit enter (this might take some time).

16. Then type “mingw32-make install” and hit enter again

    等待編譯,結束后需要的東西都在install文件夾里面了。把<build_directory>\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

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM