At the beginning of the installation environment was not successful for a long time, so I gave up temporarily and used virtual machines first. After doing a few jobs, the virtual machine becomes stuck... So I have to continue to study how to use vscode to build the operating environment on win. There are many tutorials on the Internet, but they are messy. After a long time, I finally succeeded. I sorted out the following steps, hoping to save you time.Copy the code
1. Install CMake
(1) download the CMakeThe installation package(Choose the suffixmsiBinary file download)
(2) Choose when installingAdd CMake to the system PATH for all users(Path to add system environment variables)
(3) Check whether the installation is successful (cmake –help)
2. Install the Gcc compiler mingw
(1) to downloadThe installation package(selectposixVersion)
(2) Decompress the installation package and add the bin directory to the PATH environment variable
(3) check whether the installation is successful (enter g++ -v)
3. Install VSCode and install the following plug-ins
(1) C/C++, microsoft
(2) Cmake, twxs
(3) Cmake Tool, microsoft
4. Eigen library compilation
(1) to downloadEigen
(2) Decompress to any directory and create folder build under eigen root directory
(3) Open the installed software CMake
(4) Enter the corresponding directory
Eigen root directory (IE :C:\Users\Downloads\eigen)
Fill in the directory of the new build folder in Step 2 (IE :C:\Users\Downloads\eigen\ Build).
Click Configure, select MinGW Makefiles, click Finish and wait for Runing to end
Click the generate (6)
(7) Administrator permission run CMD, enter build directory, run mingw32-make, run mingw32-make install
(8) Delete the folder extracted from Step 2
Eigen has been installed on disk C Program File x86, in case the wrong path is found during build
5. OpenCV library compilation
(1) Download and installOpenCV(I’m using 3.1.4.10.)
(2) Add PATH environment variable
E:\ mingw-w64 \x64-4.8.1-release-posix-seh-rev5\mingw64\bin (note: fill in according to your actual installation path)
(3) Create the opencv_mingw64_build folder in the root directory
(4) Open the installed software CMake
(5) Fill in the corresponding directory
Opencv \sources (IE :C:\Users\Downloads\ Opencv \sources)
Fill in the directory of the new opencv_mingw64_build folder in Step 3 (IE :C:\Users\Downloads\ opencV \opencv_mingw64_buil)
(6) Click configure, and select MinGW Makefiles and Specify Native Compilers in the pop-up format
(7) Click Next and set the path
Compiler C is in the path
Mingw64 \ bin \ GCC. Exe (ie: E: \ MinGW – w64 \ x64-4.8.1 – release – posix – seh – rev5 \ mingw64 \ bin \ GCC exe),
The Complier C++ path is
mingw64\bin\g++.exe
(ie: E: \ MinGW – w64 \ x64-4.8.1 – release – posix – seh – rev5 \ mingw64 \ bin \ g + + exe)
(Note to fill in according to your actual installation path)
(8) Click Finsh and Configure
(9) Search for the following configurations in the following locations and select or deselect them respectively
1) check the WITH_OPENGL
(2) check the ENABLE_CXX11
③ Deselect WITH_IPP
④ Deselect ENABLE_PRECOMPILED_HEADERS
⑤ Deselect OPENCV_ENABLE_ALLOCATOR_STATS
Click the Generate (10)
(11) Run CMD to go to Step 3. (3) Create the opencv_mingw64_build folder
Run the mingw32-make -j 8 command. Mingw32-make -j 8
(13) Run the mingw32-make install command
To set the opencV environment variables, run CMD, run setx -m OpenCV_DIR path_to_build/lib/, and add path_to_build/bin to the PATH environment variables
6. The configuration vscode
(1) modify the C++ include path configuration
Add C: Program Files (x86)\Eigen3\include
(2) CMakeLists fill in eigen path
find_package(Eigen3 REQUIRED)
include_directories(“C:\Program Files (x86)\Eigen3\include\”)
Ctrl+Shift+P in VSCode, select GCC
(4) Click Build in the lower left corner
Reference:
Win10+VSCode – Zhihu (zhihu.com)
OpenCV using CMake and mingw-w64 compiler installation _ huha-csDN blog
Get started with CMake Tools on Linux (visualstudio.com)