Cross compilation using pkg_config crate

I’m trying to cross-compile libudev-sys, which relies on the pkg-config-rs (and pkg_config under it) to find libraries. I was wondering if anyone has any successful examples of cross-compiling a crate that relies on pkg_config, either libudev-sys or another one. I’m a little familiar with cross-compilation in general, but I’m having a hard time understanding what the various environment variables need to be set to, and if any additional packages need to be installed, to make this happen. I’m locally running Fedora, but my CI setup is running Debian/Ubuntu, so examples using either of those platforms would be ideal.

pkg-config does not support cross-compilation, unless you manually configure it to look for libraries not on your host system, but in a specially installed "sysroot" containing libraries for the target operating system:

Thanks, but that’s the overall part of the process I already understood. I’m looking for specific examples that I can reference. Like other crates already doing this.

This is understood, but how exactly should you configure the PKG_CONFIG crate to allow cross compilation?
Can you show the syntax of how this configuration should be written in RUST please?

1 Like