我似乎无法使用 Cargo 为我的 Rust 项目构建 Opencv?

问题描述 投票:0回答:1

这是我遇到的错误

   Compiling opencv v0.91.3
error: failed to run custom build command for `opencv v0.91.3`

Caused by:
  process didn't exit successfully: `/Users/baguma/Desktop/vkrust/target/debug/build/opencv-24a3479338500f97/build-script-build` (signal: 6, SIGABRT: process abort signal)
  --- stderr
  dyld[16064]: Library not loaded: '@rpath/libclang.dylib'
    Referenced from: '/Users/baguma/Desktop/vkrust/target/debug/build/opencv-24a3479338500f97/build-script-build'
    Reason: tried: '/Users/baguma/Desktop/vkrust/target/debug/deps/libclang.dylib' (no such file), '/Users/baguma/Desktop/vkrust/target/debug/libclang.dylib' (no such file), '/Users/baguma/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libclang.dylib' (no such file), '/Users/baguma/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libclang.dylib' (no such file), '/Users/baguma/lib/libclang.dylib' (no such file), '/usr/local/lib/libclang.dylib' (no such file), '/usr/lib/libclang.dylib' (no such file)

我明白了所有胡言乱语的含义。我使用 home-brew 在我的系统上安装了 opencv,但我想我需要为 rust 进行特定安装,所以我转到

crates.io
并将 opencv 版本粘贴到我的 Cargo.toml 中

然后尝试运行cargo build,除了这个之外,所有其他包都构建成功。

编辑: 这是

cargo.toml
文件

[package]
name = "rust-opencv"
version = "0.1.0"
edition = "2021"

[dependencies]
opencv = "0.91.3"
cgmath = "0.18.0"
algebra = "0.2.0"

opencv rust rust-cargo
1个回答
0
投票

您需要启用

clang-runtime
功能才能在MacOs上正确构建
libclang

[dependencies]    
opencv = { version = "0.91.3", features = ["clang-runtime"] }
© www.soinside.com 2019 - 2024. All rights reserved.