[Debichem-devel] Bug#1148933: openms: FTBFS with hdf5 2.2: ld: cannot find -lhdf5_cpp-shared
Valentin Haudiquet
valentin.haudiquet at canonical.com
Fri Sep 25 11:29:06 BST 2026
Package: openms
Version: 2.6.0+cleaned1-6
Severity: important
Tags: patch ftbfs
X-Debbugs-Cc: valentin.haudiquet at canonical.com
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu stonking ubuntu-patch
Dear Maintainer,
Debian's binNMU 2.6.0+cleaned1-6+b2 ("Rebuild against libhdf5-320") failed
on all release architectures, currently attributed to the GCC-16 FTBFS
(#1133596) and the eigen3 5.0 FTBFS (#1136312), which abort the build at
the compile stage. Once those are fixed, the same rebuild will fail at the
link stage (at least that is what happens in Ubuntu) with:
/usr/bin/ld.bfd: cannot find -lhdf5_cpp-shared: No such file or directory
Cause: hdf5 2.2 installs a CMake config package with non-namespaced
imported targets, hdf5-shared and hdf5_cpp-shared. FindHDF5 reports the
bare target names in HDF5_CXX_LIBRARIES. OpenMS stores those names in the
cached OpenMS_LIBRARIES variable (openms_add_library). src/topp and
src/utils read OpenMS_LIBRARIES from directory scopes where the imported
targets do not exist, so CMake passes -lhdf5_cpp-shared to the linker. No
file matches that name. The real library is libhdf5_serial_cpp.so.320.
Ubuntu carries the same hdf5 and hit this on all 6 compiled architectures.
The attached patch marks the imported targets IMPORTED_GLOBAL after
find_package(HDF5), so they resolve to full library paths in every scope.
With the patch, openms 2.6.0+cleaned1-6ubuntu1 builds against hdf5 2.2 on
amd64, amd64v3, arm64, ppc64el and s390x, with riscv64 in progress.
Launchpad bug with build logs and PPA builds:
https://bugs.launchpad.net/ubuntu/+source/openms/+bug/2167933
*** /tmp/tmplklyj0a8/bug_body
In Ubuntu, the attached patch was applied to achieve the following:
* d/patches: make HDF5 imported targets global for hdf5 2.2 (LP: #2167933)
Thanks for considering the patch.
-- System Information:
Debian Release: forky/sid
APT prefers resolute-updates
APT policy: (500, 'resolute-updates'), (500, 'resolute-security'), (500, 'resolute'), (100, 'resolute-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: riscv64
Kernel: Linux 7.0.0-34-generic (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
-------------- next part --------------
diff -Nru openms-2.6.0+cleaned1/debian/patches/fix-hdf5-imported-target-scope.patch openms-2.6.0+cleaned1/debian/patches/fix-hdf5-imported-target-scope.patch
--- openms-2.6.0+cleaned1/debian/patches/fix-hdf5-imported-target-scope.patch 1970-01-01 01:00:00.000000000 +0100
+++ openms-2.6.0+cleaned1/debian/patches/fix-hdf5-imported-target-scope.patch 2026-09-22 13:11:49.000000000 +0200
@@ -0,0 +1,43 @@
+Description: Make HDF5 imported targets global so they resolve in all scopes
+ HDF5 >= 2.2's config package (hdf5-config.cmake) defines non-namespaced
+ imported targets (hdf5-shared, hdf5_cpp-shared, ...). CMake's FindHDF5
+ therefore reports bare target names in HDF5_CXX_LIBRARIES instead of
+ library paths. Those bare names are stored in cached <target>_LIBRARIES
+ variables (see openms_add_library) which are consumed from sibling
+ directory scopes (src/topp, src/utils, class tests) where the imported
+ targets are not visible. CMake then falls back to plain linker flags
+ (-lhdf5_cpp-shared) which do not match any library file, breaking the
+ build against hdf5 2.2:
+ .
+ ld: cannot find -lhdf5_cpp-shared
+ .
+ Marking the targets IMPORTED_GLOBAL makes them visible everywhere, so
+ they resolve to full paths (and keep their interface definitions) on
+ every link line, exactly as they already do when linking libOpenMS
+ itself from src/openms.
+Author: Valentin Haudiquet <valentin.haudiquet at canonical.com>
+Forwarded: https://bugs.launchpad.net/ubuntu/+source/openms/+bug/2167933
+Last-Update: 2026-09-22
+
+diff --git a/src/openms/cmake_findExternalLibs.cmake b/src/openms/cmake_findExternalLibs.cmake
+index 4e6b1f14..1b3fdd2c 100644
+--- a/src/openms/cmake_findExternalLibs.cmake
++++ b/src/openms/cmake_findExternalLibs.cmake
+@@ -142,6 +142,18 @@ endif()
+ find_package(HDF5 COMPONENTS C CXX HL REQUIRED)
+
++# make the imported targets visible to sibling scopes (LP: #2167933)
++if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.11)
++ foreach(_hdf5_target IN ITEMS
++ hdf5 hdf5_hl hdf5_cpp hdf5_hl_cpp
++ hdf5-static hdf5_hl-static hdf5_cpp-static hdf5_hl_cpp-static
++ hdf5-shared hdf5_hl-shared hdf5_cpp-shared hdf5_hl_cpp-shared)
++ if(TARGET ${_hdf5_target})
++ set_property(TARGET ${_hdf5_target} PROPERTY IMPORTED_GLOBAL TRUE)
++ endif()
++ endforeach()
++endif()
++
+ #------------------------------------------------------------------------------
+ # Done finding contrib libraries
+ #------------------------------------------------------------------------------
diff -Nru openms-2.6.0+cleaned1/debian/patches/series openms-2.6.0+cleaned1/debian/patches/series
--- openms-2.6.0+cleaned1/debian/patches/series 2026-01-03 18:00:00.000000000 +0100
+++ openms-2.6.0+cleaned1/debian/patches/series 2026-09-22 12:12:25.000000000 +0200
@@ -3,3 +3,4 @@
fix-glpk-version-check.patch
# disable_seqan1_headers.patch
add_missing_boost_header.patch
+fix-hdf5-imported-target-scope.patch
More information about the Debichem-devel
mailing list