OpenCV 2.4.11 users may have noticed that it does not provide pre-built binaries (Libs and DLLs) for VC14 (Visual Studio 2015) Unfortunately it is also the case with Qt 5.5.1 (At least it’s true at the time of writing this article) so if you are going to use either one of them you have to build it yourself.
I was also faced with this obstacle so I decided to write a guide for anyone who wishes to built OpenCV for VC14.To do that, just follow the steps below:
Note 1: This guide is already tested with CMake 3.4.1, OpenCV 2.4.11 and Visual Studio 2015 but there is a very high chance that it would work with later versions too, but I’m not sure about previous versions, you have to test it for yourself.
Note 2: You are not required to use the same folders. You may extract OpenCV sources somewhere different and also install the binaries to another place but throughout my guide and in the pictures you’ll see the same paths.
So, here it is.
- First run CMake and set the required folders.
- Source codes are in the existing folder that can be found inside OpenCV folder after its installation
- The second folder you see below is the one that will be created during the build.
- Click yes after you are warned with the message shown below.
- Now click configure. Then select “Visual Studio 14 2015” from the list. Note that you can also select WIN64 for a 64 build but in this guide I am creating a x86 build.
- Wait for the process to finish.
- Do not change any settings at this stage, just click on Generate.
- After generate is finished, close CMake and run Visual Studio Community 2015. Then open “OpenCV.SLN” file from the build directory.
- After the solution is opened, just right click on the solution’s name and Rebuild.
- After building for Debug mode ends change the build type to release, then right click and run Rebuild again.
- This concludes this tutorial. You have built all required libraries for OpenCV to use with Visual Studio 2015 (Visual C++ 2015) or Visual C++ 14.0. You can find the LIB and DLL files in separate folders. Debug and Release build folders are also created inside them.
If you have any questions just put a comment below.