Hi,
How are -sys crates detecting that a library is present in the standard locations, especially when the library is not known to pkg-config? I'm a bit surprised that there does not seem to be a crate to help with that (besides pkg-config, vcpkg) so many sys crates seem to roll their own search procedure to find whether the library is present on various systems. Did I miss something? Are there recommendations about how to proceed?
Most -sys crates just use pkg-config combined with some library-specific alternatives (e.g. there's llvm-config and png-config that work like pkg-config, but just for their own library).
There's no universal tool for this, because C libraries themselves are not uniform. The rules vary between platforms (e.g. on macOS it depends if a library ships with the OS, whether the OS version is any good, and whether Brew has a better alternative) and details vary between libraries (e.g. libjpeg has multiple ABI versions).
I'm afraid there's a wide spectrum of "it depends", from just searching a handful of dirs for libfoo.so to a complete wild west where everything is broken in ways you haven't imagined.
If you target only dynamic linking, only Linux and similar-enough BSDs, with a library that has only one ABI, one name, then it's pretty simple, because the distros did all the hard work for you.
But beyond that, you start doing all of the work that Linux distros do, but as a Rust crate, and you're going to have to deal with all of the quirkiness of Windows, macOS, and maybe iOS and Android too.
Thanks for your perspective @kornel. It is not always easy to decide what the best course of action is when a library doesn't use the standard tools to advertise itself...
Yes but I'm not familiar with writing pkg-config files and the library has sub-libraries that can individually be turned on/off so I'll need some time to work that out. I'll eventually probably submit a PR (instead of an issue for now) but, given it will certainly take more than a year to end up in Linux distributions, I also need a shorter term solution.