
Probe system pkg-config to locate libraries, enforce version constraints, and honor target-scoped environment variables for cross-compilation; line-by-line transliteration with full function and test parity.
This is a Kotlin Multiplatform line-by-line transliteration port of rust-lang/pkg-config-rs.
Original Project: This port is based on rust-lang/pkg-config-rs. All design credit and project intent belong to the upstream authors; this repository is a faithful port to Kotlin Multiplatform with no behavioural changes intended.
This is a complete Kotlin Multiplatform port of pkg-config (0.3.32) with full function and test parity against the upstream Rust crate (51/51 source functions from src/lib.rs and 28/28 test functions from tests/test.rs). Every Kotlin file carries a // port-lint: source <path> or // port-lint: tests <path> header naming its upstream Rust counterpart so the AST-distance tool tracks provenance.
The text below is reproduced and lightly edited from
https://github.com/rust-lang/pkg-config-rs. It is the upstream project's own description and remains under the upstream authors' authorship; links have been rewritten to absolute upstream URLs so they continue to resolve from this repository.
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
system-deps to declare all your
pkg-config dependencies in Cargo.toml.
This library requires Rust 1.31+.
Find the system library named foo, with minimum version 1.2.3:
fun main() {
Config.new().atleastVersion("1.2.3").probe("foo").unwrap()
}Find the system library named foo, with no version requirement (not
recommended):
fun main() {
probeLibrary("foo").unwrap()
}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.
The supported variables are: PKG_CONFIG_PATH, PKG_CONFIG_LIBDIR, and
PKG_CONFIG_SYSROOT_DIR.
Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order:
<var>_<target> - for example, PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
<var>_<target_with_underscores> - for example,
PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
<build-kind>_<var> - for example, HOST_PKG_CONFIG_PATH or
TARGET_PKG_CONFIG_PATH
<var> - a plain PKG_CONFIG_PATH
This crate will allow pkg-config to be used in cross-compilation if
PKG_CONFIG_SYSROOT_DIR or PKG_CONFIG is set. You can set
PKG_CONFIG_ALLOW_CROSS=1 to bypass the compatibility check, but please note
that enabling use of pkg-config in cross-compilation without appropriate
sysroot and search paths set is likely to break builds.
Some Rust sys crates support building vendored libraries from source, which may
be a work around for lack of cross-compilation support in pkg-config.
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.
dependencies {
implementation("io.github.kotlinmania:pkg-config-kotlin:0.1.2")
}./gradlew build
./gradlew testSee AGENTS.md and CLAUDE.md for translator discipline, port-lint header convention, and Rust → Kotlin idiom mapping.
This Kotlin port is distributed under the same MIT license as the upstream rust-lang/pkg-config-rs. See LICENSE (and any sibling LICENSE-* / NOTICE files mirrored from upstream) for the full text.
Original work copyrighted by the pkg-config-rs authors.
Kotlin port: Copyright (c) 2026 Sydney Renee and The Solace Project.
Thanks to the rust-lang/pkg-config-rs maintainers and contributors for the original Rust implementation. This port reproduces their work in Kotlin Multiplatform; bug reports about upstream design or behavior should go to the upstream repository.
This is a Kotlin Multiplatform line-by-line transliteration port of rust-lang/pkg-config-rs.
Original Project: This port is based on rust-lang/pkg-config-rs. All design credit and project intent belong to the upstream authors; this repository is a faithful port to Kotlin Multiplatform with no behavioural changes intended.
This is a complete Kotlin Multiplatform port of pkg-config (0.3.32) with full function and test parity against the upstream Rust crate (51/51 source functions from src/lib.rs and 28/28 test functions from tests/test.rs). Every Kotlin file carries a // port-lint: source <path> or // port-lint: tests <path> header naming its upstream Rust counterpart so the AST-distance tool tracks provenance.
The text below is reproduced and lightly edited from
https://github.com/rust-lang/pkg-config-rs. It is the upstream project's own description and remains under the upstream authors' authorship; links have been rewritten to absolute upstream URLs so they continue to resolve from this repository.
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
system-deps to declare all your
pkg-config dependencies in Cargo.toml.
This library requires Rust 1.31+.
Find the system library named foo, with minimum version 1.2.3:
fun main() {
Config.new().atleastVersion("1.2.3").probe("foo").unwrap()
}Find the system library named foo, with no version requirement (not
recommended):
fun main() {
probeLibrary("foo").unwrap()
}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.
The supported variables are: PKG_CONFIG_PATH, PKG_CONFIG_LIBDIR, and
PKG_CONFIG_SYSROOT_DIR.
Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order:
<var>_<target> - for example, PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
<var>_<target_with_underscores> - for example,
PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
<build-kind>_<var> - for example, HOST_PKG_CONFIG_PATH or
TARGET_PKG_CONFIG_PATH
<var> - a plain PKG_CONFIG_PATH
This crate will allow pkg-config to be used in cross-compilation if
PKG_CONFIG_SYSROOT_DIR or PKG_CONFIG is set. You can set
PKG_CONFIG_ALLOW_CROSS=1 to bypass the compatibility check, but please note
that enabling use of pkg-config in cross-compilation without appropriate
sysroot and search paths set is likely to break builds.
Some Rust sys crates support building vendored libraries from source, which may
be a work around for lack of cross-compilation support in pkg-config.
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.
dependencies {
implementation("io.github.kotlinmania:pkg-config-kotlin:0.1.2")
}./gradlew build
./gradlew testSee AGENTS.md and CLAUDE.md for translator discipline, port-lint header convention, and Rust → Kotlin idiom mapping.
This Kotlin port is distributed under the same MIT license as the upstream rust-lang/pkg-config-rs. See LICENSE (and any sibling LICENSE-* / NOTICE files mirrored from upstream) for the full text.
Original work copyrighted by the pkg-config-rs authors.
Kotlin port: Copyright (c) 2026 Sydney Renee and The Solace Project.
Thanks to the rust-lang/pkg-config-rs maintainers and contributors for the original Rust implementation. This port reproduces their work in Kotlin Multiplatform; bug reports about upstream design or behavior should go to the upstream repository.