Closed Jesse-Millwood closed 2 years ago
It looks like the issue might be the filenames of the shared libraries.
Because you haven't enabled any clang-sys
features, it will by default attempt to link to the shared libraries dynamically (rather than loading them at runtime with the runtime
feature or linking them statically with the static
feature).
This means it will look for shared libraries with the filename patterns mentioned in the error message:
['libclang.so', 'libclang-*.so']
.
None of the shared libraries you listed match these patterns so they are not being selected.
I have found that these shared libraries with the trailing version numbers cannot be linked to by ld
so they are not included as linking candidates except when the runtime
feature is enabled (because then the filename doesn't matter).
You'll either need to do runtime linking or create symlinks with an ld
-compatible name like libclang-13.so
. This might be possible by installing a different package, possibly something like libclang-dev
. (not familiar with Pop!_OS
).
There is room for improvement in clang-sys
here though. Perhaps the library finding code could recognize that it has encountered shared libraries with these unusable filenames and make the above suggestion (runtime
feature or symlink).
Hey @KyleMayes , thanks for the time you put into the response. I'm an idiot. I installed llvm-dev
and not libclang-dev
.
For what it's worth, it does look like the libclang.so
points to a libclang.so.1
:
─➤ ls /usr/lib/llvm-13/lib/libclang.* -la
lrwxrwxrwx 1 root root 39 Oct 3 16:38 /usr/lib/llvm-13/lib/libclang.so -> ../../x86_64-linux-gnu/libclang-13.so.1
lrwxrwxrwx 1 root root 16 Oct 3 16:38 /usr/lib/llvm-13/lib/libclang.so.1 -> libclang-13.so.1
When buiding a project with
cargo-sys
as a dependency, It fails to compile the crate, reporting it cannot find the libclang library.I have a very minimal project with a Cargo.toml:
I have tried building like this:
Where
which llvm-config
returns/usr/bin/llvm-config
andllvm-config --libdir
returns/usr/lib/llvm-13/lib
, and there is the following:My operating system is Pop!_OS 21.10. My rustc version is 1.58.1. I installed libclang-dev from apt.
Am I missing something here? Does anyone have this issue? I ran into this issue when trying to build
opencv-rust
and have recreated it in an even more minimal project.