How to fix cargo build error: The system library required by crate was not found.
Problem
When building a Rust project with Cargo, you might encounter an error like this:
The system library `libpcsclite` required by crate `pcsc-sys` was not found.
The file `libpcsclite.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
The PKG_CONFIG_PATH environment variable is not set.
Solution
The solution is below the error message in the cargo
output. Depending on your linux distribution, you need to install the appropriate development package that provides the libpcsclite.pc
file.
HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `libpcsclite.pc`.
If you are using Debian (or a derivative), try:
$ sudo apt install pkgconf libpcsclite-dev
If you are using Arch (or a derivative), try:
$ sudo pacman -S pkgconf pcsclite
If you are using Fedora (or a derivative), try:
$ sudo dnf install pkgconf pcsc-lite-devel
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow