=== Detected OpenCV module header dir at: /nix/store/rlf6jmwp306wr1bv2gi7bhcq7kwn9bhj-opencv-4.9.0/include/opencv4/opencv2
=== Found OpenCV version: 4.9.0 in headers located at: /nix/store/rlf6jmwp306wr1bv2gi7bhcq7kwn9bhj-opencv-4.9.0/include/opencv4
=== Generating code in: /home/amv/Projects/dev/target/debug/build/opencv-c5368590cc5f4abf/out
=== Placing generated bindings into: /home/amv/Projects/dev/target/debug/build/opencv-c5368590cc5f4abf/out/opencv
=== Using OpenCV headers from: /nix/store/rlf6jmwp306wr1bv2gi7bhcq7kwn9bhj-opencv-4.9.0/include/opencv4
thread 'main' panicked at /home/amv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-binding-generator-0.89.0/src/generator.rs:387:33:
Can't initialize clang: "the `libclang` shared library at /usr/lib/libclang.so.16.0.6 could not be opened: libLLVM-16.so: cannot open shared object file: No such file or directory"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
At the same time inside nix-shell I have:
> ls /usr/lib|grep libclang
libclang-cpp.so
libclang-cpp.so.16
libclang.so
libclang.so.16
libclang.so.16.0.6
> ls /usr/lib|grep LLVM
LLVMgold.so
libLLVM-16.0.6.so
libLLVM-16.so
libLLVM.so
libLLVMDemangle.a
libLLVMSupport.a
libLLVMTableGen.a
So I don’t understand what’s wrong and how to solve this issue.
welcome @mamaf!
Two observations that stand out to me:
you’ll want to grab the llvmPackages.libclang too
libclang does not provide pkg-config files upstream so nix doesn’t appear to magically find them. So you need to populate the correct environment variable that points to the libraries
I’m curious if you can do this in a one liner. I was able to load nix-shell -p pkg-config opencv llvmPackages.libclang but couldn’t figure out how to specify a shellHook.
That said, I’d recommend you create an ad hoc shell environment as it makes this much simpler. If you are unfamiliar with that, check out the nix.dev guide: Ad hoc shell environments — nix.dev documentation