Win7 64-bit + VS2015 +opencv3.3.0 recompile

Source: Internet
Author: User
Tags delete cache
win7x64 + VS2015 + Opencv3.3.0 re-compiling

Reference articles:
Http://blog.csdn.net/dcrmg/article/details/54097419#comments

Reference articles:
Http://www.cnblogs.com/freedomshe/archive/2013/01/11/win7_vs2012_opencv_rebuild.html

Reference articles:
http://blog.csdn.net/winnie_rq/article/details/52124974 One, download installation

In the official website http://opencv.org/releases.html Download opencv3.3.0, decompression put in D disk directory, no installation.

In the official website https://cmake.org/download/Download CMake3.8.2, decompression put in D disk directory, no installation.

Second, recompile 1. The OPENCV project of generating VS2015 with CMake

The first step: Open CMake unpacked folder, in the directory D:\cmake-3.8.2-win64-x64\bin double-click Cmake-gui.exe;

The second step: in the pop-up cmake window, input opencv source path;

Step three: Create a new folder in the D disk directory Myopencv, for the generated OPENCV project storage directory, if not created, as if the error box after configure, prompted "error inconfiguration process, project Files may be invalid ";

Fourth step: Click on "Configure" button;

Step Fifth: Select compiler visual Studio 14 2015 in the Pop-up dialog box (note that this compiler generates x86 files. If compiling a 64-bit DLL should choose 64-bit, I chose 32 here (unintentionally, when I didn't know it at the time of the election), However, after looking at the Internet that generally use 32-bit compiler, 32-bit and 64-bit after the operation should be similar;

After you follow the above settings, click Finish to start the first build. Maybe my speed is slow, others say 2min is good, my whole process down, have seen two episodes of "Friends".

After the first build

Sixth step: After the first "Configure" build, but also need to execute the build a second time, click the "Configure" button again, to perform a second build;

Seventh step: After two times "Configure", click the "Generate" button to generate the final OPENCV solution. Exit CMake.

2, with VS2015 compiler to build their own OpenCV library

The first step: after the build in the folder you created MYOPENCV view the generated items, double-click to open the project OpenCV.sln;

The second step: Select the All_build under Cmaketargets, right-click the build;
Step Three: Select the install under Cmaketargets, right-click the build;

Step Fourth: After the build, open the Myopencv folder, copy the install folder to D:\OPENCV, and rename install to vc14x86. At this time D:\MyOpenCV useless, but can not delete, otherwise can not track the source code, said on the internet can be "clean up the solution" to reduce, I have not tried.

Copy the install folder under D:\OPENCV and rename it to Vc14x86.

Third, the configuration environment 1. Environment variable Configuration

Right-click the computer-> Properties-> advanced system Settings-> advanced-> environment variables, locate the path in the system variable, click Edit, add the path:

D:\opencv\vc14x86\x86\vc14\bin

2, VS2015 in the configuration

First step: Add the environment variable, open VS2015, create a new empty C++win32 console project, and add a CPP file in the source file, such as: main.cpp;

Step Two: Open the menu bar View-> Other Window-> Properties window, select Debug| in the Property manager list Win32-> Microsoft.Cpp.Win32.user, right click on the attribute (note if the previous generation is x64, you should choose debug|x64) to configure the properties;

Step three: Common attributes-> VC + + directory-> include directory add

D:\opencv\vc14x86\include

D:\opencv\vc14x86\include\opencv

D:\opencv\vc14x86\include\opencv2

Fourth step: Common attributes-> VC + + Directory-> Library directory add

D:\opencv\vc14x86\x86\vc14\lib


Fifth step: Common Properties-> linker-> Input-> Additional dependencies add

Opencv_calib3d330d.lib

Opencv_core330d.lib

Opencv_dnn330d.lib

Opencv_features2d330d.lib

Opencv_flann330d.lib

Opencv_highgui330d.lib

Opencv_imgcodecs330d.lib

Opencv_imgproc330d.lib

Opencv_ml330d.lib

Opencv_objdetect330d.lib

Opencv_photo330d.lib

Opencv_shape330d.lib

Opencv_stitching330d.lib

Opencv_superres330d.lib

Opencv_video330d.lib

Opencv_videoio330d.lib

Opencv_videostab330d.lib

Four, test

Write the following code in MAIN.CPP:

Set breakpoints into the Imread function:

v. Errors that occur during configuration 1. Error one

Error One : The first time you click Configure Error prompts: "Error in configuration process, project files may be invalid"

workaround : Create a new Folder Myopencv in the D disk directory.

2, error two

error Two : When you click Configure after the error is resolved: "CMake error at cmakelists.txt:127 (Project): No Cmake_cxx_compiler could is Found ".

This is because the default compiler is visual Studio 15 2017, said online CMake will automatically choose this machine has been installed target compilers, I did not change, but click "Finish" after the pop-up error.

workaround : Change the default target compiler, first click on the File->delete Cache in the upper-left corner of the CMake, and then select the purge before choosing. VS2015 corresponds to the VC14, you should choose Visual Studio 14 2015 (note here, this version is generated by the x86, a lot of the internet to say this problem, but I did not pay special attention to the choice of this compiler. Remember that there is a visual Studio 2015 x64, forget what the specific name, remember that there is a 64, select that compiler generated should be x64. But it doesn't matter, generate x86 also use the same)

3. Error three

error three : According to other people's Reference articles, double-click OpenCV.sln directly after F5 compile, will pop up this error prompts: Unable to start the program: "D:\MyOpenCV\Debug\ALL_BUILD", the system can not find the specified file.

Workaround : Click OK, select All_build under Cmaketargets, right-click Build, select Install, right-click Build (refer to the steps above)

4, error four

error Four : The following error prompts: "The source file is different from the file when the module was generated." Whether you want the debugger to use it. ”

This should be my previous choice is x64, the final generation is x86.

Workaround : Click "Yes".

Related Article

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.