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 a year ago
- Comments: 35 (15 by maintainers)
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!
I can see the problem now. The general idea is that all crates using
clang-sys
must either all enable itsruntime
feature or all not. It won’t work if some are enabling it and some are not (at least with rustedition
before 2021 withresolver
before 2).In your case there are 3 dependencies that are using
clang-sys
:opencv
,v4l
andlibspa
. The latter two are using it viabindgen
. Thebindgen
crate enables theruntime
feature ofclang-sys
by default, but allows opting out of it.The problem is that
v4l
usesbindgen
with default features (=runtime
enabled), butlibspa
uses it with default features disabled (=runtime
disabled). Neither of those allow you to control it (withopencv
you can optionally enableruntime
by usingclang-runtime
feature).So long story short, your build will fail even without
opencv
and to solve it you should either enabled the default features withbindgen
inlibspa-sys
or disable them inv4l2-sys
and adjust theclang-runtime
feature foropencv
accordingly. 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.
@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
0.81.5 works with “clang-runtime” feature enabled, thanks
@zhouzq-thu
In my Cargo.toml like this
and build by
all above is success
Can you try using