Win10 system configures opencv failure record under vscode
Preface
To start learning opencv this week, we must first have a compilation environment. I chose the lightweight player vscode as the editor and MinGW as the compiler. I tried to complete the compilation environment under the blessing of cmake, but it ended in failure. This article is simple Record the problems encountered and the solutions, as well as the unsolvable problems.
Each software version
vscode: the latest version of
opencv downloaded from the official website : 4.5.0
MinGW: use the latest version of the downloader to download
cmake: 3.18.2
Software installation process
vscode
vscode go directly to the official website, you should have a hand
opencv
The installation of opencv is also the official website. In the release, download after selection, as shown in the red box:
after clicking in, select the red box to download:
after the download is complete, it is this file:
double-click to install.
MinGW
I used a downloader to download the MinGW installation. Although I installed a cpp compilation environment for vscode before, I was worried about any problems, so I used the official downloader.
The specific installation method is based on this blog post, which is very detailed:
https://blog.csdn.net/wxh0000mm/article/details/100666329
You may need a good network environment to download.
CMake
CMake is downloaded from the official website, here:
https://cmake.org/download/
After entering, find the red box location to download:
Stepped pit
There are mainly two places that stumped me along the way, and most of them are still harmonious. The following describes the pits I encountered.
CMake generates configuration file error
In summary, it can be calledCannot download files such as ffmpeg and xfeatures2d when compiling OpenCV with Cmake
When I used CMake to generate the compiled files, I just completed two configures and one generate mechanically, but I didn't notice that there was an error! ! !
When an error is reported, a section of red text will appear in CMake-gui. I thought it was a normal phenomenon, but it is not. The error message is probably like this:
Refer to this article for the solution:
https://www.jianshu.com/p/52de9de70891
This is an article by a senior boss, and the person is very good, and it helped me solve many problems.
Also explain some of the details mentioned in the article:
The download of the correct version mentioned here, I downloaded the latest one directly, and I found it easy to use. Judging whether the correct version needs to see whether the MD5 number matches.
In addition, download the entire compressed package when downloading, and some cannot download the final file directly from GitHub, just download the compressed package and unzip the required files.
After replacing the file, I went back to configure again and there was no error in red letters, a great article!
Error when MinGW32-make
Since I don’t know exactly what these steps are, I posted a step diagram, that is, when executing the red box, a very terrible error occurred, but it couldn’t pass no matter what:
My error message is like this:
3rdparty\openexr\CMakeFiles\IlmImf.dir\build.make:137: recipe for target ‘3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfAttribute.cpp.obj’ failed
mingw32-make[2]: *** [3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfAttribute.cpp.obj] Error 1
CMakeFiles\Makefile2:1791: recipe for target ‘3rdparty/openexr/CMakeFiles/IlmImf.dir/all’ failed
mingw32-make[1]: *** [3rdparty/openexr/CMakeFiles/IlmImf.dir/all] Error 2
Makefile:180: recipe for target ‘all’ failed
mingw32-make: *** [all] Error 2
This problem has not been solved in fact, but I tried to compile it with the following command (from the advice of the blogger mentioned above)
cd /d “D:\Program Files\OpenCV\opencv\build\x64\MinGW\3rdparty\openexr” && C:\MinGW\bin\g++.exe -I “D:\Program Files\OpenCV\opencv\sources\3rdparty\openexr\IlmImf” -c “D:\Program Files\OpenCV\opencv\sources\3rdparty\openexr\IlmImf\ImfAttribute.cpp” -o CMakeFiles\IlmImf.dir\IlmImf\ImfAttribute.cpp.obj
The effect is that a certain file is missing:
I then adopted the -I "absolute address" method to ignore the missing certain file. The approximate effect is as follows:
Layers of files are recursively missing, until the last layer, a bunch of errors are reported, and the Method failed:
Briefly explain the usage requirements of the instruction, which should be placed before -c in the initial instruction, where I is the capital of i, and the absolute path of the file should be the absolute path of the .h file, and cannot include the file itself, for example Example:
The absolute path of this half.h is in the path bar above, as follows:
D:\Program Files\OpenCV\opencv\sources\3rdparty\openexr\Half
At the same time, my absolute path contains spaces, so I have to add double quotes to the absolute path. If there are no spaces, I don’t need to add it. I didn’t try this.
Finally, I decided to try again with other versions of OpenCV and CMake. I haven't tried it yet. I will update it after I try.
Special thanks
Thank you very much to the blogger mentioned above: Beiming Youyu wyh
helped me a lot in the configuration process and guided me very patiently, this little white, I would like to express my sincere thanks! ! !
If you have any pointers or details that you want to know, you are very welcome to send me a private message, we will learn together and make progress together!