когда я использую bindgen в ржавчине, мне не удалось выполнить llvm-config: Os {code: 2, kind: NotFound error

В build.rs:

extern crate bindgen;

use std::env;
use std::path::PathBuf;
use std::{process::Command, str};
fn main() {
    println!("cargo:rustc-link-lib=llvm");
    println!("cargo:rerun-if-changed=TransverseMercatorWrapper.hpp");

    let llvm_config_out = Command::new("llvm-config")
        .args(&["--cxxflags", "--ldflags", "--system-libs", "--libs", "core"])
        .output()
        .expect("failed to execute llvm-config");

    let llvm_clang_args = llvm_config_out
        .stdout
        .split(|byte| byte.is_ascii_whitespace())
        .map(|arg| str::from_utf8(arg).unwrap());

    let bindings = bindgen::Builder::default()
        .header("TransverseMercatorWrapper.hpp")
        .clang_arg("-x").clang_arg("--").clang_arg("c++") // c++ flag
        .clang_args(llvm_clang_args)
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .generate()
        .expect("unable to generate bindings");

    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    bindings
        .write_to_file(out_path.join("bindings.rs"))
        .expect("couldn't write bindings!");
}

Когда я использую cargo build --realease, У меня такие ошибки:

D:\big_test\rust\pl_qin>cargo build --release
   Compiling pl_qin v1.0.0 (D:\big_test\rust\pl_qin)
error: failed to run custom build command for `pl_qin v1.0.0 (D:\big_test\rust\pl_qin)`

Caused by:
  process didn't exit successfully: `D:\big_test\rust\pl_qin\target\release\build\pl_qin-471767ea7fc89a35\build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-lib=llvm
cargo:rerun-if-changed=TransverseMercatorWrapper.hpp

--- stderr
thread 'main' panicked at 'failed to execute llvm-config: Os { code: 2, kind: NotFound, message: "系统找不到指定的文件。" }', build.rs:13:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Кто-нибудь знает почему?

0 ответов

Другие вопросы по тегам