opencv-rust: a `libclang` shared library is not loaded on this thread
Before reporting an issue please first check the
- Operating system: Fedora 38
- The way you installed OpenCV: package
- OpenCV version: opencv-devel-4.7.0-2.fc38.x86_64
- rustc version: rustc 1.69.0 (84c898d65 2023-04-16)
- Attach the full output of the following command from your project directory:
RUST_BACKTRACE=full cargo build -vv
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 35 (15 by maintainers)
Commits related to this issue
- krun-sys: Expose the option to select how libclang native library is loaded `krun-sys` depends on the bindgen crate which in turn depends on clang-sys, but `clang-sys` has a curious problem: Let's sa... — committed to mtjhrc/libkrun by mtjhrc a year ago
- krun-sys: Expose feature for configuring libclang loading `krun-sys` depends on the bindgen crate which in turn depends on clang-sys, but `clang-sys` has a curious problem: Let's say you are compilin... — committed to mtjhrc/libkrun by mtjhrc a year ago
- krun-sys: Expose feature for configuring libclang loading `krun-sys` depends on the bindgen crate which in turn depends on clang-sys, but `clang-sys` has a curious problem: Let's say you are compilin... — committed to mtjhrc/libkrun by mtjhrc a year ago
- krun-sys: Expose feature for configuring libclang loading `krun-sys` depends on the bindgen crate which in turn depends on clang-sys, but `clang-sys` has a curious problem: Let's say you are compilin... — committed to mtjhrc/libkrun by mtjhrc a year ago
Since version 0.86.1 you should be getting a more friendly message when libclang loading mismatch is detected: https://github.com/twistedfall/opencv-rust/blob/730cc64955ab4ad5286bee891e795a1322b053c0/build/generator.rs#L74-L77. Thanks for the suggestion!
Ah yep (macOS) opencv = { version = “0.85.3”, features = [“clang-runtime”] }
Maybe there is a way to detect target, or flag the error with some helper somehow, README.md warning? Either way working ok, thanks
I can see the problem now. The general idea is that all crates using
clang-sysmust either all enable itsruntimefeature or all not. It won’t work if some are enabling it and some are not (at least with rusteditionbefore 2021 withresolverbefore 2).In your case there are 3 dependencies that are using
clang-sys:opencv,v4landlibspa. The latter two are using it viabindgen. Thebindgencrate enables theruntimefeature ofclang-sysby default, but allows opting out of it.The problem is that
v4lusesbindgenwith default features (=runtimeenabled), butlibspauses it with default features disabled (=runtimedisabled). Neither of those allow you to control it (withopencvyou can optionally enableruntimeby usingclang-runtimefeature).So long story short, your build will fail even without
opencvand to solve it you should either enabled the default features withbindgeninlibspa-sysor disable them inv4l2-sysand adjust theclang-runtimefeature foropencvaccordingly. That can be done by either creating issues or PRs in the corresponding repositories or forking the repos and doing the necessary changes yourself.0.81.5 works with “clang-runtime” feature enabled on macOS. Thanks.
0.81.5 works with “clang-runtime” feature enabled, thanks
@jaques-sam Ah, wait, I’ve missed the fact that you’re using OpenCV 3.2, that version is no longer supported so you should probably stick with whatever crate version works for you until you are able to switch to OpenCV 3.4 or 4.x
@zhouzq-thu
In my Cargo.toml like this
and build by
all above is success
Can you try using