plotters-rs / plotters

A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely 🦀 📈🚀
https://plotters-rs.github.io/home/
MIT License
3.88k stars 281 forks source link

No package 'freetype2' found #196

Open colindaven opened 4 years ago

colindaven commented 4 years ago

The error

configure: error: Package requirements (freetype2) were not met:

No package 'freetype2' found

could be solved on Ubuntu 20.04 with sudo apt install libfreetype6-dev

Ragarnoy commented 3 years ago

This makes cross compilation (ie. compiling from MacOS for linux) kind of impossible ? I haven't found a fix yet. This needs a fix.

Monadic-Cat commented 2 years ago

This makes cross compilation (ie. compiling from MacOS for linux) kind of impossible ? I haven't found a fix yet. This needs a fix.

@Ragarnoy, @MrGibus hey, I just searched for issues with cross compiling with plotters, cause my PR for adding a different backend feature which uses a pure Rust text rendering library was merged recently. Are you still dealing with this?

Edit: That is to say, cross compiling plotters is now relatively easy with the right feature set.

MrGibus commented 2 years ago

I didn't think the additional dependency was too restrictive in Linux. No plans to work on this.

qarmin commented 9 months ago

With plotters 0.3.5 I have now this error, so looks that still cross compilation is hard/unavailable

cross build --target armv7-unknown-linux-gnueabihf --release
# or
cargo build --target armv7-unknown-linux-gnueabihf --release
error: failed to run custom build command for `yeslogic-fontconfig-sys v3.2.0`

Caused by:
  process didn't exit successfully: `/target/release/build/yeslogic-fontconfig-sys-88f49ca8bf2e6e30/build-script-build` (exit status: 101)
  --- 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_ALLOW_CROSS_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_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_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at /cargo/registry/src/index.crates.io-6f17d22bba15001f/yeslogic-fontconfig-sys-3.2.0/build.rs:8:48:
  called `Result::unwrap()` on an `Err` value: "\npkg-config exited with status code 1\n> PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/: PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags fontconfig\n\nThe system library `fontconfig` required by crate `yeslogic-fontconfig-sys` was not found.\nThe file `fontconfig.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.\nPKG_CONFIG_PATH contains the following:\n    - /usr/lib/arm-linux-gnueabihf/pkgconfig/\n    - \n\nHINT: you may need to install a package such as fontconfig, fontconfig-dev or fontconfig-devel.\n"
Monadic-Cat commented 9 months ago

@qarmin The answer is cross compilation is hard, if you need to use fontconfig. You'll need to create a cross sysroot.

You could try disabling the ttf feature and using the ab_glyph one instead. See the list of features.

I actually added the ab_glyph feature specifically to make it easier for me to cross compile something I was doing to run on an ARM machine, way back when.

cometta commented 1 month ago

anyone successfully cross compile from MacOS M1 to x86 ? can share the config please?

qarmin commented 1 month ago
plotters = { version = "0.3", default-features = false, features = ["all_series", "bitmap_backend", "ab_glyph"] }
pub fn register_pdf_fonts() {
    // Simple unwrap not works yet - https://github.com/plotters-rs/plotters/issues/539
    let res = register_font("roboto-regular", FontStyle::Normal, FONT_ROBOTO_REGULAR);
    if res.is_err() {
        panic!("Unable to register font");
    } else {
        info!("Pdf fonts registered");
    }
}
let diagram_font = ("roboto-regular", 20).into_font();
let diagram_text_style = TextStyle::from(diagram_font).color(&BLACK);

works fine when cross-compiling from x86_64 -> arm_32

cometta commented 1 month ago

@qarmin, i need the other way round arm to x86. anyone else tested this?

qarmin commented 1 month ago

This not depends on any system libraries, so cross-compilation should work for any configuration