Build library for invoking pkg-config for Rust

License: Other

Language: Rust


Build Status Rust


A simple library meant to be used as a build dependency with Cargo packages in order to use the system pkg-config tool (if available) to determine where a library is located.

You can use this crate directly to probe for specific libraries, or use metadeps to declare all your pkg-config dependencies in Cargo.toml.

This library requires Rust 1.30+.


Find the system library named foo, with minimum version 1.2.3:

extern crate pkg_config;

fn main() {

Find the system library named foo, with no version requirement (not recommended):

extern crate pkg_config;

fn main() {

External configuration via target-scoped environment variables

In cross-compilation context, it is useful to manage separately PKG_CONFIG_PATH and a few other variables for the host and the target platform.


Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order:

  1. <var>_<target> - for example, PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  2. <var>_<target_with_underscores> - for example, PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  3. <build-kind>_<var> - for example, HOST_PKG_CONFIG_PATH or TARGET_PKG_CONFIG_PATH
  4. <var> - a plain PKG_CONFIG_PATH

Also note that PKG_CONFIG_ALLOW_CROSS must always be set in cross-compilation context.


This project is licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in pkg-config-rs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Project Statistics

Sourcerank 18
Repository Size 874 KB
Stars 61
Forks 40
Watchers 6
Open issues 16
Dependencies 0
Contributors 31
Tags 10
Last updated
Last pushed

Top Contributors See all

Alex Crichton Sebastian Dröge Toru Ogawa Steven Fackler Ivan Ukhov Eli Flanagan Kornel Gleb Kozyrev Shang Linwei Danilo Bargen Mathieu Poumeyrol Eunchong Yu Josh Triplett Pierre Lejeune Kyle Galloway Ratamovic Fernando Jiménez Moreno Brian Anderson Keegan McAllister Robin Gloster

Packages Referencing this Repo

A library to run the pkg-config system tool at build time in order to be used in Cargo build scri...
Latest release 0.3.17 - Updated - 61 stars

Recent Tags See all

0.3.16 September 09, 2019
0.3.15 July 25, 2019
0.3.14 August 28, 2018
0.3.13 August 06, 2018
0.3.12 July 18, 2018
0.3.11 April 24, 2018
0.3.10 April 23, 2018
0.3.9 January 24, 2017
0.3.8 March 08, 2016
0.3.7 February 17, 2016

Something wrong with this page? Make a suggestion

Last synced: 2019-11-02 09:38:04 UTC

Login to resync this repository