HappySeaFox / sail

The missing small and fast image decoding library for humans (not for machines) ⛵ https://sail.software
MIT License
308 stars 22 forks source link

Allow compiling dependencies for codecs into single library #192

Closed Blackclaws closed 1 year ago

Blackclaws commented 1 year ago

Sail is pretty awesome as a library. My one problem right now is that I want to use it in Unity and in mobile applications and the dependency on shared system libraries is a bit of a problem.

When you compile sail using standard cmake and create shared libraries that include the codecs you end up with a couple of shared libraries that have dependencies on each other. Even worse they have dependencies on system libraries such as libz, etc.

I would like to build libsail for distribution where it does not have a dependency on any system library, similar to how it works for freeimage which compiles libjpeg,libz, etc. directly into itself. This is also an issue if you want to use sail in an embedded system where you aren't linking against a running system.

This might be a bit contrary to the portable nature of sail but I really find that sail is superior in usability to freeimage but has a drawback in this department.

Maybe I am also just missing how to correctly do this. So guidance would be appreciated.

HappySeaFox commented 1 year ago

Thanks for the idea! 👍 I understand the problem and I can recommended to try alternative ways to achieve it. Sail is a simple and a portable library, not a build system. I don't like the idea to make a library have build system attributes like FreeImage does. This way we end up having outdated external dependencies and a library hell. I prefer using external build systems for that. For example, you can try compiling sail as a shared library with combined codecs enabled(SAIL_COMBINED_CODECS=ON), and against the static vcpkg triplet. This way all external dependencies will be compiled into the combined codecs library sail-codecs.dll. This solution is still not perfect as we still have sail-common.dll, sail.dll etc. but at least it significantly reduces the number of files. Any other ideas are welcomed!

HappySeaFox commented 1 year ago

The vcpkg way has been added in the FAQ: https://sail.software/faq.html#can-i-compile-codecs-dependencies-like-libjpeg-directly-into-sail

The latest master is required for that as I commited a couple of configuration fixes.