开发者问题收集

无法运行“yeslogic-fontconfig-sys v3.2.0”的自定义构建命令

2023-02-11
1854

我正在尝试学习如何在 Rust 中绘图,并找到了一个使用绘图仪的指南(如果有人知道更好的绘图库,请告诉我。)

https://plotters-rs.github.io/book/intro/getting_started.html

无论如何,我在 Fedora 37 上,在使用本指南入门部分中显示的示例时遇到了问题。

代码是:

/*
Example of plotting in Rust
*/

use plotters::prelude::*;

fn main() {
    
    let root_drawing_area = BitMapBackend::new("0.1.png", (1024, 768))
        .into_drawing_area();

    root_drawing_area.fill(&WHITE).unwrap();

    let mut chart = ChartBuilder::on(&root_drawing_area)
        .build_cartesian_2d(-3.14..3.14, -1.2..1.2)
        .unwrap();

    chart.draw_series(LineSeries::new(
        (-314..314).map(|x| x as f64 / 100.0)
        .map(|x| (x, x.sin())), &RED))
        .unwrap();

}

在我的 cargo.toml 文件中,我使用 cargo add plotters 添加了依赖项

但是当我使用 cargo build 运行代码时,我收到此错误:

Compiling yeslogic-fontconfig-sys v3.2.0
error: failed to run custom build command for `yeslogic-fontconfig-sys v3.2.0`

Caused by:
  process didn't exit successfully: `/home/usr/Dev/RustyKrab/plotting/plot_example/target/debug/build/yeslogic-fontconfig-sys-3bf9e95194fbfdbd/build-script-build` (exit status: 101)

并继续stdout

--- stdout
  cargo:rerun-if-env-changed=RUST_FONTCONFIG_DLOPEN
  cargo:rerun-if-env-changed=FONTCONFIG_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=FONTCONFIG_STATIC
  cargo:rerun-if-env-changed=FONTCONFIG_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

和 stderr

--- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "`\"pkg-config\" \"--libs\" \"--cflags\" \"fontconfig\"` did not exit successfully: exit status: 1\nerror: could not find system library 'fontconfig' required by the 'yeslogic-fontconfig-sys' crate\n\n--- stderr\nPackage fontconfig was not found in the pkg-config search path.\nPerhaps you should add the directory containing `fontconfig.pc'\nto the PKG_CONFIG_PATH environment variable\nPackage 'fontconfig', required by 'virtual:world', not found\n"', /home/usr/.cargo/registry/src/github.com-1ecc6299db9ec823/yeslogic-fontconfig-sys-3.2.0/build.rs:8:48

错误的最后一行是 注意:使用 `RUST_BACKTRACE=1` 环境变量运行以显示回溯 。我尝试运行 RUST_BACKTRACE=1 alacritty ,但根本不起作用。

我该如何解决这个问题,以便在 Rust 中使用绘图仪?

注意:我已使用 sudo dnf install fontconfig

安装了 fontconfig
2个回答

@john-kugelman 在问题的评论中回答了这个问题。要解决此处的错误,我必须使用以下命令安装 fontconfig 的开发工具:

sudo dnf install fontconfig-devel
Shane Gervais
2023-03-29

对于使用 Linux Mint 的用户,您需要使用 libfontconfig1-dev ,从我所见,我怀疑其他基于 Debian 的发行版也是如此

Pioneer_11
2024-05-16