kornelski / dssim

Image similarity comparison simulating human perception (multiscale SSIM in Rust)
https://kornel.ski/dssim
GNU Affero General Public License v3.0
1.07k stars 69 forks source link

Question: Can a shared library be built? #131

Closed th0ma7 closed 1 year ago

th0ma7 commented 1 year ago

Looking into integrating dssim to a gstreamer|ffmpeg project for Synology NAS. https://github.com/SynoCommunity/spksrc/pull/5298

I was able to build the binary with no issue so far.

My question is, in your README you refer to it being also available as library. Is there an option to pass to generate the library and install the include files?

Thnx.

kornelski commented 1 year ago

I haven't added a C interface for it. Currently it's a Rust library for Rust projects, and its public API uses generic types/traits that are impossible to express in a C header file.

You could write your own small wrapper for dssim in Rust, which does whatever comparison you want, and makes it available through your custom extern "C" function that the rest of your code can call. If you compile that with crate-type = ["cdylib"] or use cargo-c you can build a proper C-compatible dynamically-linked library.

th0ma7 commented 1 year ago

Thnx, that explains. And I figured that gstreamer simply checks for the existence of the binary and does not bind to any library pertaining to it. So my overall build looks good.