Cmake: Error in configuration process, project files may be invalid. Qt's experience in compiling opencv.

Error in configuration process,project files may be invalid.

I use cmake to compile opencv +Qt.

This path of Qt should be placed in the path of the environment variable: E:\Qt5\Qt5.14.1\Tools\mingw730_64\bin.

The reason for the error is that the Cmake interface buttons are not operated in sequence.

1. Configure CMake compilation conditions

① Open CMake (cmake-gui).

②Select the source code file in the OpenCV installation directory: D:\Qt\opencv3.40\opencv\sources

③Choose the path of the directory file you want to compile and output. If it is stored in a unified directory, create a new opencvbuild3.40 folder under the D:\Qt file and select this path: D:\Qt\opencvbuild3.40
 

The above steps are simple, just select the source file path and build path (create the build folder by yourself), the next two steps are optimistic, this is a compiler for qt, not a compiler for vs2015 or 2017.

④Click Configure to configure.

⑤Select MinGWMakefiles , check Special native compilers and click Next

Be sure to see clearly, in order,

⑥ Configure the compiler

In Figure 1 below, the C compiler selects D:\Qt\Qt5.10.0\Tools\mingw530_32\bin\gcc.exe;

In Figure 2 below, the C++ compiler selects D:\Qt\Qt5.10.0\Tools\mingw530_32\bin\g++.exe

Fortran does not need to fill in, and then click finish. Note: This process ensures that the network is smooth , because several files need to be downloaded.
 

⑦ After waiting for a while, a bunch of red will appear, check WITH_QT and WITH_OPENGL (if you need and have the OPENGL library, check it; otherwise don’t check it), ENABLE_CXX11 (otherwise the error 'nullptr' was not declared in this scope), Cannot check WITH_IPP (not checked by default), click configure again.

Then click configure, if an error is reported, modify the path and lib library of qmake, as shown in the figure:

Click configure again, report an error, modify the opengl path,:

Mine didn't report an error. And I also in the Qt configuration, configured Cmake

I compiled successfully: no error was reported, and then click Generate, the result is as shown below

This creates a lot of files in the build

Next step Compile OpenCV

1. Shift + right-click in the blank space of the folder generated by compilation, and select "Open command window here". Enter the "mingw32-make" command and press Enter to compile.

Note: This build is the folder I created myself to place the files generated by Cmake.

 

 Then: enter the cmd command line, the path is under the current path. Type mingw32-make

Be careful not to report errors. After running.

Create an install folder in build and execute the following command

mingw32-make install

 After running, you can get the following files in the install folder

 inlude is the opencv header file

There are lib and bin files in x64.

At this point, the process of qt +cmake + compiling and configuring opencv ends

Guess you like

Origin blog.csdn.net/Vertira/article/details/132629590