opencv-rust: Windows, exit code: 0xc0000135, STATUS_DLL_NOT_FOUND

Windows 10 Installed opencv 4.2.0 by downloading binaries from the website. Default Hello World Program

Cargo.toml

[dependencies]
opencv = {version = "0.33", features = ["buildtime-bindgen"]}

cargo run

Compiling opencv v0.33.1
error: failed to run custom build command for `opencv v0.33.1`                          

Caused by:
  process didn't exit successfully: `C:\Users\grasb\OneDrive\Documents\Code\rust_test\target\debug\build\opencv-cbf104b9e94d4794\build-script-build` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)

How do i fix this? It seems to be the final hurdle before I can successfully use rust with opencv on windows.

EDIT: For those that stumble upon this

  • Make sure Clang is installed.
  • install llvm and opencv from their websites (vcpkg didn’t work for me and was very slow to install because it decided to recompile windows?)
  • Make sure to properly set your environment variables OPENCV_LINK_LIBS=opencv_world420
  • restart your system to update your environment variables
  • put the dlls from your opencv install directory: C:\opencv\build\x64\vc14\bin next to your built rust executable or add C:\opencv\build\x64\vc14\bin to PATH environment variable otherwise you will get a STATUS_DLL_NOT_FOUND error

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 16 (6 by maintainers)

Most upvoted comments

That means that Windows can’t find one of the dll files referenced by the binary. Alas, it doesn’t say which one. You can try copying all of the dlls from OpenCV distribution (it should actually be the only one: opencv_world_something.dll) to the directory where you binary is (C:\Users\grasb\OneDrive\Documents\Code\rust_test\target\debug\build\opencv-cbf104b9e94d4794\ in your example) and see if it helps. Checking the binary dependency tree with dependency walker also helps in tracking down which dll files are required. Ultimately you’d want to set up PATH to point where OS can find the necessary dlls.

You might want to check the Windows part of the CI script for some inspiration: https://github.com/twistedfall/opencv-rust/blob/master/ci/script.sh#L5

@GRASBOCK

put the dlls from your opencv install directory: C:\opencv\build\x64\vc14\bin next to your built rust executable otherwise you will get a STATUS_DLL_NOT_FOUND error

Can you update this part as

put the dlls from your opencv install directory: C:\opencv\build\x64\vc14\bin next to your built rust executable or add C:\opencv\build\x64\vc14\bin to PATH environment variable otherwise you will get a STATUS_DLL_NOT_FOUND error

Just adding an environment variable is an easier solution than copying hundreds of megabytes for each package.

IT WORKS 😮 Thank you so much! The nightmare if hopefully over!