Repository: linebender/resvg (language: rust)

Issue:
Provide pkg-config file with the C library
Providing a [pkg-config file](https://en.wikipedia.org/wiki/Pkg-config) makes it easier for users of the library to actually find it, check its version and get the correct compiler and linker flags.

[cargo-c](https://github.com/lu-zero/cargo-c) could be helpful here for generating the pkg-config file and also to provide a mechanism for installing it, the library itself and the header. It also ensures that the library has a valid and correct soname set, which cargo doesn't set at all when building a `cdylib`.

`cargo-c` also allows running cbindgen automatically but AFAIU you're manually editing the output of it so that's maybe not very useful here.


Discussion / hints:
It will also make static linking easier as all the required linker flags would be part of the pkg-config file
I'm not familiar with `pkg-config` or `cargo-c`, so unless someone wants to make a PR it would take a while for me to figure it all out.
Out of scope unless someone would send a path.
You might want to add something to the README.md that Linux distros should not package it for the time being then as without a proper soname etc it's only going to cause problems. I'm not using resvg myself and only reported that here because someone ran into such problems and had the impression that Rust's build tools are too immature for providing proper C shared libraries. (Which is kind of true if only using cargo, like in your project here)
>without a proper soname

Afaik this is a cargo bug, not resvg one. And Linux-only one. It's up to distro maintainers to decide what to do. Out of scope.
Fine with me, next time someone complains about stuff being broken I'll just point them to this issue :)

> Linux-only one

On macOS you don't get proper dylib versioning either.

> Afaik this is a cargo bug

More a missing feature than a bug, but until then cargo alone is unsuitable for this purpose.

https://github.com/rust-lang/cargo/issues/5045 and https://github.com/rust-lang/cargo/issues/2273 FWIW

Fix patch:
diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml
index 23451439..42dbd07c 100644
--- a/crates/c-api/Cargo.toml
+++ b/crates/c-api/Cargo.toml
@@ -26,3 +26,10 @@ system-fonts = ["resvg/system-fonts"]
 # enables font files memmaping for faster loading (only for `text`)
 memmap-fonts = ["resvg/memmap-fonts"]
 raster-images = ["resvg/raster-images"]
+capi = []
+
+[package.metadata.capi.header]
+generation = false
+
+[package.metadata.capi.install.include]
+asset = [{ from="resvg.h" }]


Test patch: