Commit 72666842 for libheif
commit 726668421f6371e4cca9f66d0c2aad0d7a04b6d2
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Fri May 22 17:07:11 2026 +0200
when webp is enabled, link defensively to pthread (#1816)
diff --git a/heifio/CMakeLists.txt b/heifio/CMakeLists.txt
index ee0365d2..c7291549 100644
--- a/heifio/CMakeLists.txt
+++ b/heifio/CMakeLists.txt
@@ -114,6 +114,15 @@ if(WEBP_FOUND)
target_link_libraries(heifio PRIVATE WebP::webp)
target_link_libraries(heifio PRIVATE WebP::libwebpmux)
+ # libwebp uses pthreads internally, but depending on how it was built
+ # (e.g. autotools, where libtool may drop '-pthread') its shared object can
+ # lack a DT_NEEDED entry for libpthread. On systems where pthread is not
+ # part of libc (glibc < 2.34) linking against libwebp then fails with
+ # unresolved 'pthread_create'/'pthread_join'. Link Threads defensively so
+ # the symbols are always satisfied; this is a no-op where pthread is in libc.
+ find_package(Threads REQUIRED)
+ target_link_libraries(heifio PRIVATE Threads::Threads)
+
target_sources(heifio PRIVATE encoder_webp.cc encoder_webp.h)
target_sources(heifio PRIVATE decoder_webp.cc decoder_webp.h)
endif()