How to Build OpenCV 2.4.13 Static/Dynamic with MSVC2010

OpenCV 2.4.13 was released just a few days ago and as a tradition I had to check if a static build with Microsoft Visual C++ 2010 (MSVC2010) 32-bit produced any errors or not. Fortunately, everything went quite smoothly (except a few common warnings here and there) and I was able to successfully build it so if you need to build the latest OpenCV release statically using MSVC2010 you can follow the steps below:

First of all, make sure you have the latest CMake installed on your computer. (I am using CMake 3.4.3) You can download it from here if you don’t have it already.

You need to also download OpenCV 2.4.13 from official OpenCV website.

You must also download and install Microsoft Visual C++ 2010 Express (which is free). You can Google for it.

Extract OpenCV files to any folders you want. In my case I am using “d:cvopencv” which you will also notice from the pictures below but you can use any other folders that you like.

Run CMake (cmake-gui) and set the parameters on the screen as mentioned below (You need to set your own folders):

  • Where is the source code: D:/cv/opencv/sources
  • Where to build the binaries: D:/cv/opencv/sources/bin

Then click on Configure button. (You might be asked to create bin folder that does not exit. Just click Yes and proceed to Configure.)

At the configure page select Visual Studio 10 2010 and Check Use default native compiler.

Configure

Press Finish so that the configurations are applied.



Make sure you uncheck BUILD_SHARED_LIBS and press Generate. (This might take a few moments.)

Note: If you want to build a dynamic (shared) version of OpenCV then leave BUILD_SHARED_LIBS checked.

CMAKE OpenCV Static

After Generate is finished you can close CMake.

Open Microsoft Visual C++ 2010 Express and go to the bin folder that you set at the start of this process. You will notice there is a Visual C++ Solution file name OpenCV.sln that you can open with Microsoft Visual C++ 2010 Express. Just open it.

OpenCV



Wait for the project to load. Then select Debug as your build type (as seen in the picture)  and run Rebuild Solution.

OpenCV

After the building process is finished, change build type to Release (as seen below) and run Rebuild Solution again.

OpenCV

After the build is finished, you will notice that some entries are skipped but the majority are succeeded. Just make sure nothing is failed.



OpenCV

Finally you can find all Static Library (*.LIB) files under “BIN/LIB” folder of the build root directory, inside the Debug and Release folders.



2 Replies to “How to Build OpenCV 2.4.13 Static/Dynamic with MSVC2010”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.