1# pkg-config-rs 2 3[![Build Status](https://travis-ci.com/rust-lang/pkg-config-rs.svg?branch=master)](https://travis-ci.com/rust-lang/pkg-config-rs) 4[![Rust](https://img.shields.io/badge/rust-1.30%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/pkg-config-rs/) 5 6[Documentation](https://docs.rs/pkg-config) 7 8A simple library meant to be used as a build dependency with Cargo packages in 9order to use the system `pkg-config` tool (if available) to determine where a 10library is located. 11 12You can use this crate directly to probe for specific libraries, or use 13[metadeps](https://github.com/joshtriplett/metadeps) to declare all your 14`pkg-config` dependencies in `Cargo.toml`. 15 16This library requires Rust 1.30+. 17 18# Example 19 20Find the system library named `foo`, with minimum version 1.2.3: 21 22```rust 23extern crate pkg_config; 24 25fn main() { 26 pkg_config::Config::new().atleast_version("1.2.3").probe("foo").unwrap(); 27} 28``` 29 30Find the system library named `foo`, with no version requirement (not 31recommended): 32 33```rust 34extern crate pkg_config; 35 36fn main() { 37 pkg_config::probe_library("foo").unwrap(); 38} 39``` 40 41# External configuration via target-scoped environment variables 42 43In cross-compilation context, it is useful to manage separately PKG_CONFIG_PATH 44and a few other variables for the `host` and the `target` platform. 45 46The supported variables are: `PKG_CONFIG_PATH`, `PKG_CONFIG_LIBDIR`, and 47`PKG_CONFIG_SYSROOT_DIR`. 48 49Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order: 50 511. `<var>_<target>` - for example, `PKG_CONFIG_PATH_x86_64-unknown-linux-gnu` 522. `<var>_<target_with_underscores>` - for example, `PKG_CONFIG_PATH_x86_64_unknown_linux_gnu` 533. `<build-kind>_<var>` - for example, `HOST_PKG_CONFIG_PATH` or `TARGET_PKG_CONFIG_PATH` 544. `<var>` - a plain `PKG_CONFIG_PATH` 55 56Also note that `PKG_CONFIG_ALLOW_CROSS` must always be set in cross-compilation context. 57 58# License 59 60This project is licensed under either of 61 62 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or 63 http://www.apache.org/licenses/LICENSE-2.0) 64 * MIT license ([LICENSE-MIT](LICENSE-MIT) or 65 http://opensource.org/licenses/MIT) 66 67at your option. 68 69### Contribution 70 71Unless you explicitly state otherwise, any contribution intentionally submitted 72for inclusion in pkg-config-rs by you, as defined in the Apache-2.0 license, shall be 73dual licensed as above, without any additional terms or conditions. 74