Rust 编译错误:无法为 `clang-sys v1.6.1` 运行自定义构建命令

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

我正在尝试在内核 6.20 的 Centos 上构建 Rust 程序。当尝试编译 Rust 文件时,我不断收到以下错误消息。

cargo build --manifest-path=atropos/Cargo.toml --release
   Compiling proc-macro2 v1.0.56
   Compiling unicode-ident v1.0.8
   Compiling quote v1.0.26
   Compiling libc v0.2.141
   Compiling autocfg v1.1.0
   Compiling version_check v0.9.4
   Compiling syn v1.0.109
   Compiling serde_derive v1.0.159
   Compiling cc v1.0.79
   Compiling bitflags v1.3.2
   Compiling hashbrown v0.12.3
   Compiling serde v1.0.159
   Compiling pkg-config v0.3.26
   Compiling memchr v2.5.0
   Compiling toml_datetime v0.6.1
   Compiling thiserror v1.0.40
   Compiling winnow v0.4.1
   Compiling once_cell v1.17.1
   Compiling io-lifetimes v1.0.10
   Compiling cfg-if v1.0.0
   Compiling rustix v0.37.7
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-macro-error v1.0.4
   Compiling indexmap v1.9.3
   Compiling glob v0.3.1
   Compiling heck v0.4.1
   Compiling anyhow v1.0.70
   Compiling memoffset v0.6.5
   Compiling camino v1.1.4
   Compiling linux-raw-sys v0.3.1
   Compiling serde_json v1.0.95
   Compiling clang-sys v1.6.1
   Compiling semver v1.0.17
   Compiling aho-corasick v0.7.20
   Compiling syn v2.0.13
   Compiling regex-syntax v0.6.29
   Compiling itoa v1.0.6
   Compiling log v0.4.17
   Compiling libbpf-sys v1.1.1+v1.1.0
   Compiling minimal-lexical v0.2.1
   Compiling os_str_bytes v6.5.0
   Compiling ryu v1.0.13
   Compiling nom v7.1.3
   Compiling toml_edit v0.19.8
   Compiling clap_lex v0.2.4
error: failed to run custom build command for `clang-sys v1.6.1`

Caused by:
  process didn't exit successfully: `/root/sched_ext/tools/sched_ext/atropos/target/release/build/clang-sys-eaa3a1b9c03ac901/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'could not find any static libraries', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-1.6.1/build/static.rs:92:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
make: *** [Makefile:201: atropos] Error 101

当我使用

RUST_BACKTRACE=1
环境变量运行以显示回溯时,我得到以下信息。

or: failed to run custom build command for `clang-sys v1.6.1`

Caused by:
  process didn't exit successfully: `/root/sched_ext/tools/sched_ext/atropos/target/release/build/clang-sys-eaa3a1b9c03ac901/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'could not find any static libraries', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-1.6.1/build/static.rs:92:9
  stack backtrace:
     0: std::panicking::begin_panic
     1: build_script_build::static::find
     2: build_script_build::static::link
     3: build_script_build::main
     4: core::ops::function::FnOnce::call_once

为什么会出现此错误以及如何修复此错误?谢谢。

rust rust-cargo
1个回答
0
投票

使用

crate
opencv 时遇到类似问题,错误:

Compiling clang-sys v1.6.1
The following warnings were emitted during compilation:

warning: could not execute `llvm-config` one or more times, if the LLVM_CONFIG_PATH environment variable is set to a full path to valid `llvm-config` executable it will be used to try to find an instance of `libclang` on your system: "couldn't execute `llvm-config --prefix` (path=llvm-config) (error: No such file or directory (os error 2))"

error: failed to run custom build command for `clang-sys v1.6.1`

我正在

Ubuntu
机器上构建,因此通过安装解决了这个问题:
apt install libopencv-dev clang libclang-dev

© www.soinside.com 2019 - 2024. All rights reserved.