c++opencv

OpenCV: 32-bit libs & dlls for Visual Studio project


I am upgrading a C++ Visual Studio project that uses OpenCV 2.4 to a more recent version of OpenCV (e.g. 4.1.2 or 4.4.0). I need 32-bit and 64-bit builds of my project, so I need 32-bit and 64-bit versions of the OpenCV libs and dlls.

But recent pre-built downloadable versions of OpenCV for Windows contain libs and dlls for x64 only. I did find 32-bit and 64-bit precompiled binaries here (https://github.com/huihut/OpenCV-MinGW-Build) but they are built with MinGW and don't have the VS-compatible libs I need for linking.

I can try to build my own 32-bit version of the OpenCV libs but at first glance this looks like it could take a lot of effort. OpenCV utilizes CMake and other tools I'm not familiar with.

So my question is: can anyone point me to 32-bit build of a recent version of OpenCV that has libs built with Visual Studio? Or if not, can anyone confirm that they have built a 32-bit OpenCV with Visual Studio? If this is my only choice I'll go down this road, but I'd like to know in advance if this is difficult (for example, maybe OpenCV itself has dependencies that are not available as 32-bit?).

Any help appreciated!


Solution

  • I built OpenCV myself, it turned out not to be difficult. I followed the guides here and here. I'll put my own detailed steps below, it might help someone else.

    I am using Visual Studio Enterprise 2019. My choices are shown in parenthesis.

    For me at this point, there is a big list of items in red and in the detail area at the bottom, everything is ok except for some Python errors in red. I don't care about the Python parts, so:

    Click Configure again... wait to see the 'Configuring done' message. All the red disappears. Click Generate and wait to see the 'Generating done' message. Look in your build folder... open the solution 'OpenCV.sln' Open it in Visual Studio, build Release or Debug.

    If you want to make an x64 build, start over by doing File->Delete Cache, and select x64 at the Optional platform for generator step.