twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.96k stars 157 forks source link

Build failed on Windows 10 #573

Closed dontcryme closed 4 months ago

dontcryme commented 4 months ago
  1. Operating system : Windows 10 21He (x64)
  2. The way you installed OpenCV: package (choco install llvm opencv)
  3. OpenCV version : 4.9.0
  4. rustc version : rustc 1.75.0 (82e1608df 2023-12-21)
  5. Attach the full output of the following command from your project directory:

log.txt

twistedfall commented 4 months ago

Looks like you have a mix of clang versions. You can see that it’s using version 14 for the build, but it’s including headers from version 18 and that’s what likely leads to libclang crash:

[opencv 0.91.3] === Clang: clang version 14.0.6
[opencv 0.91.3] === Clang command line args: [
[opencv 0.91.3]     "-isystemC:\\Program Files\\LLVM\\lib\\clang\\18\\include",
dontcryme commented 4 months ago

path thank you, @twistedfall .

Sorry, I didn't figure out that error log.

I checked on another clean PC, and there was no problem, thank you.

However, from my memory, I didn't install that 'clang' 14.0.6 version.

So I found all libclang.lib and clang.exe files on my Windows machine. (attached image - there is no 14.0.6 version, and if I check "clang -v" in the Windows CLI to verify the installed status, then I get an error before executing the "choco install llvm" command)

As I understand, the 'clang_getClangVersion' function in the clang-sys crate returns the defined magic (build) number of libclang.lib, right?

I don't understand that behavior.

If I remove llvm using the command below:

"choco uninstall llvm"

and just build and execute a simple Rust program to check the clang version using the clang_sys crate, then I get the following error:

'couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll']'

But when I install llvm again with "choco install llvm", I get the following result message:

"clang version 14.0.6"

I don't know why I'm getting that 14.0.6 clang version.

And some additional clang-sys log like below: [clang-sys dynamic linking library path - all about clang 18.x version]

[clang-sys 1.7.0] Directory bin : "C:\Program Files\LLVM\bin" [clang-sys 1.7.0] filename : "libclang.dll" [clang-sys 1.7.0] cargo:rustc-link-search=C:\Program Files\LLVM\bin [clang-sys 1.7.0] cargo:rustc-link-search=C:\Program Files\LLVM\lib [clang-sys 1.7.0] cargo:rustc-link-lib=dylib=libclang

Am I missing something here~?

I know this issue is not related to the rust-opencv crate, sorry.

Updated :

I Found It. AMDDuProf is that problem. Thank you!

erikreed commented 1 month ago

I just spent hours debugging this one too: same issue where the clang version listed in the build logs was different than the clang installed via vcpkg (and clang --version). Uninstalling AMD μProf fixed it for me as well.