Skip to content

Commit

Permalink
Ensure libheif symbols are found when built statically
Browse files Browse the repository at this point in the history
libheif is a C++ library that exposes a C API. When it's built
statically, the linker must also link with the C++ stdlib, which
is done automatically when using a C++ compiler.

Prior to commit strukturag/libheif@27097a6, libheif included
libstdc++ in the `Libs.private` field of their .pc file. This meant
it was exposed in the case of static linking, enabling a build
system for a C application to link against libstdc++ as needed.
However, this was not portable as libstdc++ is specific to the GNU
toolchain, when using Clang, you can optionally use libc++.

This commit aims to find symbols in libheif using a C++ compiler,
ensuring that Meson can confirm their availability at link-time,
even when libheif is statically built.
  • Loading branch information
kleisauke committed Oct 16, 2023
1 parent 27e8688 commit fbb09fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions fuzz/oss_fuzz_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ popd

# libheif
pushd $SRC/libheif
# Ensure libvips finds heif_image_handle_get_raw_color_profile
sed -i '/^Libs.private:/s/$/ -lc++/' libheif.pc.in
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=$WORK \
Expand Down
6 changes: 3 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,14 @@ if libheif_dep.found()
endif
cfg_var.set('HAVE_HEIF', '1')
# added in 1.6.0
if cc.has_function('heif_image_handle_get_raw_color_profile', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
if cpp.has_function('heif_image_handle_get_raw_color_profile', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
cfg_var.set('HAVE_HEIF_COLOR_PROFILE', '1')
endif
if cc.has_function('heif_context_set_maximum_image_size_limit', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
if cpp.has_function('heif_context_set_maximum_image_size_limit', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
cfg_var.set('HAVE_HEIF_SET_MAX_IMAGE_SIZE_LIMIT', '1')
endif
# added in 1.7.0
if cc.has_member('struct heif_decoding_options', 'convert_hdr_to_8bit', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
if cpp.has_member('struct heif_decoding_options', 'convert_hdr_to_8bit', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
cfg_var.set('HAVE_HEIF_DECODING_OPTIONS_CONVERT_HDR_TO_8BIT', '1')
endif
# heif_main_brand added in 1.4.0, but heif_avif appeared in 1.7 ... just check
Expand Down

0 comments on commit fbb09fb

Please sign in to comment.