Skip to content

Build error: "Could not detect OpenCV version" with OpenCV 4.13.0 on Windows 11 #708

@DM10cn

Description

@DM10cn

Environment

  • Operating system: Windows 11 Pro 25H2 (Build 26200.7840)
  • OpenCV Version: 4.13.0 (Official binary distribution)
  • Rust version: rustc 1.93.1 (01f6ddf75 2026-02-11)
  • LLVM/Clang version: 22.1.0

Description of the issue

I am encountering a build failure with the opencv crate (v0.92.3). Despite manually configuring all necessary environment variables, the build script fails with:
Could not detect OpenCV version from include_paths.

I have confirmed that:

  1. opencv_version command works in PowerShell (returns 4.13.0).
  2. The path C:\opencv\build\include\opencv2\core\version.hpp is present and accessible.
  3. Environment variables are set in both System Env and .cargo/config.toml.

Current Configuration (.cargo/config.toml)

[env]
OPENCV_VERSION = "4.13.0"
OPENCV_INCLUDE_PATHS = "C:\\opencv\\build\\include"
OPENCV_LINK_PATHS = "C:\\opencv\\build\\x64\\vc16\\lib"
OPENCV_LINK_LIBS = "opencv_world4130"
LIBCLANG_PATH = "C:\\APP\\LLVM\\bin"

build_log.txt

Additional Context
It seems the build script's regex/probing logic might be incompatible with the header format in OpenCV 4.13.0 on Windows, or it's failing to prioritize the manually provided OPENCV_VERSION variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions