QT5.4.2MINGW Compiling configuration opencv2.4.9

Source: Internet
Author: User
1 Download the tools you need

(1) Qt-opensource-windows-x86-mingw491_opengl-5.4.2.exe 842M

Download Address https://download.qt.io/archive/qt/5.4/5.4.2/

(2) OpenCV for Windows (Opencv-2.4.9.exe 348M)

Download Address http://opencv.org/downloads.html

(3) Cmake-2.8.12.2-win32-x86.exe 10M

Download Address https://cmake.org/files/v2.8/ 2 installing QT 5.4.2

The process is simple, choose Components to select all, installation prompt step by step. The default installation path is C:\Qt\Qt5.4.2, be careful not to drastically change the path, I just changed C to D, so my installation path is d:\Qt\Qt5.4.2 3 installation OpenCV2.4.9

It is not so much an installation as extracting it to a location.

Double-click the Opencv-2.4.9.exe, the decompression path to the D-disk, the easier the better, do not give yourself trouble. As shown in figure


After the decompression is completed, a OpenCV folder will be generated in the D drive, as shown below:



4 Installing the CMake (1) The installation path cannot have Chinese and spaces (2) tick add all environment variables



5 Set the system environment variable of QT, need to set two

Make Path D:\Qt\Qt5.4.2\Tools\mingw491_32\bin

Qmake Path D:\Qt\Qt5.4.2\5.4\mingw491_32\bin

Click on the path, then click Edit, press the computer's home button to position the cursor at the beginning of the value of the variable box, and then paste the two paths, the different paths should be separated by a semicolon in the English state.


6. Open CMake, compile with CMake OpenCV

(1) Set the source path and the generated target path

D:/opencv/sources is the 3rd step to extract OpenCV after the source path generated

D:/opencv/compile This compile path is a new folder that I created under d:/opencv/to hold the compiled generated files.

(2) Click the Configure button (first click Configure). In the popup dialog box, select Mingwmakefiles, as shown in the following illustration


Then click Next and set the following:

C:d:\qt\qt5.4.2\tools\mingw491_32\bin\gcc.exe

C + +:d: \qt\qt5.4.2\tools\mingw491_32\bin\g++.exe

Fortran not required


The results that appear after clicking Finish are as follows:


It means that the work in front of you is doing well ...


(3) Check the above list of With_opengl and WITH_QT two, the other items are best not to change.



(4) Click Configure Again (second click Configure), the results are as follows:



Although there will be many warnings, such as this warning are for project developers. Use-wno-dev to suppress it, but it will not affect our final success.

(5) Click the Generate button to generate the makefile file, after success, the bottom will prompt generating done. There will be some warning, I will not screenshot, basically (2) step success, the back is very smooth, I was stuck in the second step for a long time. 7 open cmd to compile

(1) Enter the target path you just set (D:/opencv/compile)

First Enter D: Enter D, then enter cdopencv/compile into the Compile folder

(2) then enter the Mingw32-make command to start compiling, the process is about 25 minutes
(3) then enter Mingw32-make install this process takes about 1-2 minutes
8 Starting the OPENCV development environment to configure QT creator (1) Copy D:\opencv\build's include directory to D:\OPENCV



(2) Copy D:\opencv\compile bin and Lib directory (7th, 8 step generated files) to D:\OPENCV


(3) After copying the results as shown in the figure, just keep the box selected three directories, other directories can be deleted.


(4)   Add the bin directory to the system environment variable
 
9 load Qt5 compiled OPENCV library #此库用于Qt-MINGW Programming
# MinGW version of QT5 load QT5 compiled library
Includepath + = d:\opencv\include\
Includepath + = d:\opencv\include\opencv\
Includepath + = d:\opencv\include\opencv2\
12 x
libs+= d:\OpenCV\lib\libopencv_core249.dll.a\
d:\OpenCV\ Lib\libopencv_highgui249.dll.a\
//note cannot empty line
D:\OpenCV\lib\libopencv_imgproc249.dll.a\
D:\OpenCV\lib\ Libopencv_calib3d249.dll.a\
D:\OpenCV\lib\libopencv_contrib249.dll.a\
D:\OpenCV\lib\libopencv_ Features2d249.dll.a\
D:\OpenCV\lib\libopencv_flann249.dll.a\
D:\OpenCV\lib\libopencv_gpu249.dll.a\
D : \opencv\lib\libopencv_legacy249.dll.a\
D:\OpenCV\lib\libopencv_ml249.dll.a\
D:\OpenCV\lib\libopencv_ Objdetect249.dll.a\
D:\OPENCV\LIB\LIBOPENCV_VIDEO249.DLL.A

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.