rustcompiler-errorsfontconfigglium

rust glium compile error missing package on ubuntu


I try compile this in Rust with glium on an Ubutnu machine.

#[macro_use]
extern crate glium;

fn main() {
    println!("Hello, world!");
}

It results in this error:

  --- stderr
  thread 'main' panicked at '`"pkg-config" "--libs" "--cflags" "fontconfig" "fontconfig >= 2.11.1"` did not exit successfully: exit status: 1
  error: could not find system library 'fontconfig' required by the 'servo-fontconfig-sys' crate

  --- stderr
  Package fontconfig was not found in the pkg-config search path.
  Perhaps you should add the directory containing `fontconfig.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'fontconfig' found
  Package fontconfig was not found in the pkg-config search path.
  Perhaps you should add the directory containing `fontconfig.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'fontconfig' found
  ', /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-fontconfig-sys-5.1.0/build.rs:34:17
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error[E0554]: `#![feature]` may not be used on the stable release channel
   --> /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/thiserror-1.0.38/src/lib.rs:238:34
    |
238 | #![cfg_attr(provide_any, feature(provide_any))]
    |                                  ^^^^^^^^^^^

The first error says it cannot find the fontconfig library. What should I do here? How do I get that library installed? I do not know what to do with the second error, either.

OS: Ubuntu 22.04 LTS

I have added glium = "*" to cargo dependencies.

Addendum

The first error is solved after running cargo clean - but the second error still persists. Any ideas?


Solution

  • Using this command in the terminal, install the required dependency:

    sudo apt install libfontconfig1-dev