rustrust-cargorhelpangogtk-rs

pango.pc not found even though PKG_CONFIG_PATH environment variable is configured


RHEL 9.4 does not have the PKG_CONFIG_PATH environment variable configured even though pkg-config is installed. Therefore, cargo cannot build pango-sys because the pango.pc file is needed. Setting the PKG_CONFIG_PATH environment variable to /usr/lib64/pkgconfig still does not work, even though pango.pc file is in that directory.

PKG_CONFIG_PATH environment variable was to /usr/lib64/pkgconfig because the pango.pc file is in that directory. However, cargo run still says that it cannot find the pango.pc file, even though it now recognizes the PKG_CONFIG_PATH environment variable is pointed to the correct location.

[joshuasmartin@customer books]$ cargo run
   Compiling glib-sys v0.19.5
   Compiling gobject-sys v0.19.5
   Compiling gio-sys v0.19.5
   Compiling pango-sys v0.19.5
   Compiling cairo-sys-rs v0.19.2
   Compiling gdk-pixbuf-sys v0.19.5
   Compiling gdk4-sys v0.8.2
   Compiling graphene-sys v0.19.5
The following warnings were emitted during compilation:

warning: pango-sys@0.19.5: 

error: failed to run custom build command for `pango-sys v0.19.5`

Caused by:
  process didn't exit successfully: `/home/joshuasmartin/Projects/books/target/debug/build/pango-sys-b0e0c14daac28167/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=PANGO_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=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
  cargo:warning=
  pkg-config exited with status code 1
  > PKG_CONFIG_PATH=:/usr/lib64/pkgconfig PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags pango pango >= 1.49.2

  The system library `pango` required by crate `pango-sys` was not found.
  The file `pango.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  PKG_CONFIG_PATH contains the following:
      - 
      - /usr/lib64/pkgconfig

  HINT: you may need to install a package such as pango, pango-dev or pango-devel.

warning: build failed, waiting for other jobs to finish...

Solution

  • Resolved the issue by disabling pkg-config lookup of system-deps in the Cargo.toml and specifying the shared object name of pango according the instructions here:

    https://docs.rs/system-deps/1.3.2/system_deps/#overriding-build-flags

    Added the following lines to .bashrc and now the cargo run is successful:

    export SYSTEM_DEPS_PANGO_NO_PKG_CONFIG="true"
    export SYSTEM_DEPS_PANGO_LIB="pango-1.0"