google / libultrahdr

Ultra HDR is a true HDR image format, and is backcompatible. libultrahdr is the reference codec for the Ultra HDR format. The codecs that support the format can render the HDR intent of the image on HDR displays; other codecs can still decode and display the SDR intent of the image.
https://developer.android.com/guide/topics/media/platform/hdr-image-format
Apache License 2.0
146 stars 23 forks source link

add support for static linking of applications #255

Closed ram-mohan closed 1 week ago

ram-mohan commented 2 weeks ago

By default, the dependency libraries that were used during linking are shared libraries even if BUILD_SHARED_LIBS is OFF. This change ensures that their static counterparts are used if BUILD_SHARED_LIBS is disabled.

For a true static executable, the system libraries also have to be linked statically. This can be achieved by adding '-static' in linker flags. However, this is not done because this is not universal. For instance Apple does not support statically linking an entire executable. All programs must link to 'libSystem'. Making direct system calls is not supported. For MSVC, statically linking MSVC run time needs to be handled separately. For MSYS, Linux platforms it is possible to add '-static', but for simplicity this is not done.

Build: cmake -G Ninja -DBUILD_SHARED_LIBS=0 ../ Test: ./ultrahdr_app