Does opencv compiles on Windows?

No matter what, which ever compiler I use, it does not compile on Windows?
Has anyone compiled the latest 4.5.3 on windows, and what are the flags and compiler.
I had visual studio 2017 and Visual Studio 2019, and tried with older mingw and the latest mingw x86_64-8.1.0-posix-seh-rt_v6-rev0, but it always give one error or another.

Sorry looks like CMake Issue, it does not take the compiler specified but mixes different compilers. I renamed all the other compilers folder names and then it compiled with VS 2019

1 Like

See if somebody online has compiled OpenCV for Windows already. What version of Windows are you using?

there are official binary releases on Releases - OpenCV

I configure and compile on windows well. You need indeed VS2019, cmake installed and in the $env:path variables starting with $ such as $src are variables defined in a powershell script.

For instance:

$solution = "OpenCV.sln"
$base = "I:/src/opencv-4.5.3"
$src = $base + "/opencv"
$srcextra = $base + "/opencv_contrib/modules"
$builddir = $base + "/build"
$target = "Visual Studio 16 2019"
$distname = "v453_vtk903_cuda114"

$env: are environement variables, eg., $env:CUDNN where CUDNN equals C:\lib\cudnn-11.4-x64-v8.2.2.26

To configure (with a certain configuration, feel free to edit yourself):

cmake -G $target -A x64 -S $src `
        -DVTK_DIR="$Env:VTK_DIR" -DWITH_VTK=0 -DBUILD_opencv_viz=0 -DCPU_BASELINE=AVX2 `
        -DOPENCV_EXTRA_MODULES_PATH="$srcextra" -DPYTHON2_EXECUTABLE="C:\Python27\python.exe" `
        -DCUDNN_INCLUDE_DIR="$Env:CUDNN"/include -DCUDNN_LIBRARY="$Env:CUDNN"/lib/x64/cudnn.lib `

To build, rebuild, install, I use those:

        MSBuild.exe /m $solution /verbosity:m
        MSBuild.exe /m $solution /p:Configuration=Release /verbosity:m

        MSBuild.exe /m /t:Rebuild $solution /verbosity:m
        MSBuild.exe /m /t:Rebuild $solution /p:Configuration=Release /verbosity:m

        MSBuild.exe /m INSTALL.vcxproj /verbosity:m
        MSBuild.exe /m INSTALL.vcxproj /p:Configuration=Release /verbosity:m /m