How to Build OpenCV 3.1 with MSVC2010 for x86

OpenCV 3.1 was released yesterday and with a first look I noticed that prebuilt libraries for x86 VC10 (MSVC2010) are nowhere to be found in the installation folder. In fact there is no x86 folder to begin with. Some of my recent apps all are built using MSVC2010 so I had to build OpenCV myself. Here is what I did and what I suggest you should do.

Previously I wrote a guide about building OpenCV 2.4.11 with VC14. In fact building OpenCV 3.1 with VC10 is quite similar if not the same. Please read this guide first and then check out the differences below:

The only obvious and very simple differences are :

  • You need to install Microsoft Visual C++ 2010 (Express)
  • You have to select MSVC 2010 (VC10) compiler while running CMake configure.




I built OpenCV 3.1 successfully myself but if you are still unable to build using this guide then just put a comment bellow to start a conversation about it.

Good luck!

20 Replies to “How to Build OpenCV 3.1 with MSVC2010 for x86”

  1. Hi, in the x64 lib folder there is only one .lib file for release and one for debug.

    After building for x86, I have multiple .libs for both release and debug (similar to previous 2.4.12 version).

    Is this normal ?

    Thanks!

    1. Unfortunately not. And I highly recommend against using someone else’s build. I would gladly help you build one exactly like mine for yourself 🙂

  2. hi
    i want build OpenCV 3.1 with MSVC2012 FOR x64
    but in cmake when i click on configure, i get this error “error in configuration process project files may be invalid”

    how can fixed this?

  3. I’m trying to install OpenCV 3.1.0 with MSVC2012 compiler using CMake. I get an error saying that the file hash is different from the expected hash.
    Download: Local copy of opencv_ffmpeg.dll has invalid MD5 hash: d41d8cd98f00b204e9800998ecf8427e (expected: 89c783eee1c47bfc733f08334ec2e31c)

    how to fix this?

    1. Check your network connection and reconfigure again. invalid MD5 hash value means you don’t have the correct files or they are corrupted. (can happen due to a faulty connection.)

  4. I am having big trouble with it. I have successfully built it and i have the OpenCV.sln file. I am able to open the solution in ***VS15*** but I cant build it there. I get LNK1112 error. what should I do?

    I don’t even have that opencv\build\x86 folder to use in CMake, I only have x64 one. I downloaded opencv from http://opencv.org/downloads.html > OpenCV for Windows (3.1).
    What should I do?

    1. forget thesecond part of my comment. how do I solve the first part?

      Severity Code Description Project File Line Suppression State
      Error LNK1112 module machine type ‘x64’ conflicts with target machine type ‘X86’ opencv_python2 D:\tools\opencv-build\modules\python2\python27.lib(python27.dll) 1

      1. Can you tell me which version of Visual Studio you are using for building? Is it x86 or x64?

        It seems you are creating project for one version and then try to build it with another version of VS.

  5. Hello Amin,

    Thanks for the post! could you precise how to select the compiler? actually, cmake (version 3.7) proposes to “specify native compilers” at the comfiguration step. Then it asks for a path, for fortrans C and C++, which path should we give it ,if it is the right way to do? thanks in advance

    1. Usually you don’t need to specify the compiler by yourself. Are you sure you have a compiler installed and in the PATH? CMake should be able to find it automatically.

  6. Hi Amin,

    Is it possible to use latest opencv pre-built libraries for windows with visual studio 2008 for x86? or can I compile it with VS 2008?

    1. Well the question is actually about the C++ compiler that is shipped with VS 2008. So, two points:
      1. I would avoid using C++ libs meant for other compilers (or compiler versions)
      2. I would be surprised to see latest versions built with compilers that do not support C++11, and yes, VS 2008 does not ship with a compiler that supports C++11.

      I hope this helps.

      1. Hi Amin,

        I’ve succesfully build OpenCV 3.3 for x64. However we’d like to build for 32bit as well. If in cmake-gui I simply selected Visual Studio 14 2015 (as opposed to Visual Studio 14 2015 Win64) then I get errors during the configuration process that CMake cannot find 32bit versions of the CUDA libs that all of the opencv modules depend on.

        I’ve read that CUDA toolkit no longer ships 32 bit versions of their libs as they are now deprecated. I’ve also read that I could still build for 32 bit if I crossed compiled an x64 solution to target win32. Unfortunately I have no idea how to configure cmake-gui to generate a 64 bit project that targets win32, any thoughts?
        Thanks!

        1. Hmmm, sounds strange. Can you please clarify the following:

          * Do you want to build OpenCV with all default configurations?
          * Do you change anything? If so, the what exactly?

          As for the last part, I am still not sure if I got it correctly but generally speaking something that is meant for 64 bit can’t be used with 32 bit (it usually works the other way around)

          However, I am able to build OpenCV 3.3 using MSVC14 (2015) 32 bit without any issues, using all default settings.

Leave a Reply

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