Skip to content

Commit c1e4d03

Browse files
authored
Ensure libheif symbols are found when built statically (libvips#3715)
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.
1 parent 1130557 commit c1e4d03

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

fuzz/oss_fuzz_build.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ popd
6565

6666
# libheif
6767
pushd $SRC/libheif
68-
# Ensure libvips finds heif_image_handle_get_raw_color_profile
69-
sed -i '/^Libs.private:/s/$/ -lc++/' libheif.pc.in
7068
cmake \
7169
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
7270
-DCMAKE_INSTALL_PREFIX=$WORK \

meson.build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,14 @@ if libheif_dep.found()
485485
endif
486486
cfg_var.set('HAVE_HEIF', '1')
487487
# added in 1.6.0
488-
if cc.has_function('heif_image_handle_get_raw_color_profile', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
488+
if cpp.has_function('heif_image_handle_get_raw_color_profile', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
489489
cfg_var.set('HAVE_HEIF_COLOR_PROFILE', '1')
490490
endif
491-
if cc.has_function('heif_context_set_maximum_image_size_limit', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
491+
if cpp.has_function('heif_context_set_maximum_image_size_limit', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
492492
cfg_var.set('HAVE_HEIF_SET_MAX_IMAGE_SIZE_LIMIT', '1')
493493
endif
494494
# added in 1.7.0
495-
if cc.has_member('struct heif_decoding_options', 'convert_hdr_to_8bit', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
495+
if cpp.has_member('struct heif_decoding_options', 'convert_hdr_to_8bit', prefix: '#include <libheif/heif.h>', dependencies: libheif_dep)
496496
cfg_var.set('HAVE_HEIF_DECODING_OPTIONS_CONVERT_HDR_TO_8BIT', '1')
497497
endif
498498
# heif_main_brand added in 1.4.0, but heif_avif appeared in 1.7 ... just check

0 commit comments

Comments
 (0)