Compiling OpenCV on Windows 8.1

I’m setting up the latest OpenCV version from source since the Caffe dependency version installed doesn’t have some tools I want to add to my vision processing pipeline.

I started with grabbing the latest version from github
git clone

Then I used the CMake GUI. Visual Studios 12 appears to be the latest buildchain supported

If you haven’t used the GUI version of CMake before, the most import feature you’ll use while setting everything up is the File – Delete Cache command. CMake needs the cache cleared after you fail a configuration attempt or a bad environment generation.

I was really lazy after grabbing the source and didn’t check any of the dependencies involved. CMake found my Cuda installation without any extra config, but there’s a python requirement for both versions 2.7 and 3.4 which I can’t get both to open correctly. %PYTHONHOME% is a serious PITA. Hitting the generate button a few times eventually yielded a successful config regardless.

Once you get the CMake to generate a configuration you can hit the Open Project button to open the project in Visual Studios.
From there, hit Build – Build Solution to start compiling.

Everything appeared able to compile with 6955 warnings and 1 error related to a python27_d.lib linker error that hopefully only broke the python interface.
error LNK1104: cannot open file 'python27_d.lib'

An optimization that’s probably worth is exploring is explicitly picking the CUDA architecture as I think it built it for all possible versions. My suspicion stems from these warnings:
warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
And the fact that the opencv directory is now over 8GB which seems on the large side.

Leave a Comment