Closed Neumann-A closed 3 years ago
This could be related to the HDF5 version.
This could be related to the HDF5 version.
Version is 1.10.5
Probably related to:
https://github.com/InsightSoftwareConsortium/ITK/blob/ee2ab9c973e66616cc2132f9a96fcf7763a6b94d/Modules/ThirdParty/HDF5/CMakeLists.txt#L35-L40
And HDF5_CXX_(SHARED|STATIC)_LIBRARY
as well as HDF5_C_(SHARED|STATIC)_LIBRARY
not being defined in the hdf5config.cmake.
I replaced it with the targets and it works now. #1803 seems also be solved by it.
As such always try to link targets if they exists or at least check the existence of the variables before linking nothing.....
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.
I have another error when building with an external HDF5 (ITK 5.1.2, HDF5 1.8.12 built from source and found via HDF5_ROOT
, CMake 3.19.2, VS 2019):
2>LINK : fatal error LNK1104: cannot open file 'hdf5_cpp.lib' [C:\Users\krisf\Documents\devel\buildVC\SIRF-SuperBuild\builds\ITK\build\Modules\IO\HDF5\src\ITKIOHDF5.vcxproj]
This occurs 3 times (other occurrences are ITKIOMINC
and ITKIOTransformHDF5
).
Building with verbose shows for instance
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64\link.exe /ERR
ORREPORT:QUEUE /OUT:"C:\Users\krisf\Documents\devel\buildVC\SIRF-SuperBuild\builds\ITK\build\bin\RelWithDebInfo\ITKIO
TransformHDF5-5.1.dll" /INCREMENTAL /NOLOGO "..\..\..\..\lib\RelWithDebInfo\ITKIOTransformBase-5.1.lib" hdf5_cpp.lib
hdf5.lib "..\..\..\..\lib\RelWithDebInfo\ITKTransformFactory-5.1.lib" "..\..\..\..\lib\RelWithDebInfo\ITKTransform-5.
1.lib" "..\..\..\..\lib\RelWithDebInfo\ITKCommon-5.1.lib" "..\..\..\..\lib\RelWithDebInfo\itksys-5.1.lib" ws2_32.lib
dbghelp.lib psapi.lib "..\..\..\..\lib\RelWithDebInfo\ITKVNLInstantiation-5.1.lib" "..\..\..\..\lib\RelWithDebInfo\it
kvnl_algo-5.1.lib" "..\..\..\..\lib\RelWithDebInfo\itkvnl-5.1.lib" "..\..\..\..\lib\RelWithDebInfo\itkv3p_netlib-5.1.
lib" "..\..\..\..\lib\RelWithDebInfo\itkvcl-5.1.lib" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32
.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /man
ifest:embed /DEBUG /PDB:"C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/builds/ITK/build/bin/RelWithDebInfo/I
TKIOTransformHDF5-5.1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Users/krisf/Documents/devel
/buildVC/SIRF-SuperBuild/builds/ITK/build/lib/RelWithDebInfo/ITKIOTransformHDF5-5.1.lib" /MACHINE:X64 /machine:x64 /
DLL ITKIOTransformHDF5.dir\RelWithDebInfo\itkHDF5TransformIO.obj
ITKIOTransformHDF5.dir\RelWithDebInfo\itkHDF5TransformIOFactory.obj
Note the "bare" filenames for the HDF5 libraries, which is wrong as they are not in a system location. In fact, I have to set the location by passing HDF5_ROOT
. Setting HDF5_FIND_DEBUG=ON
gives the following output of cmake
(showing only the HDF5 output):
-- HDF5_DIR: HDF5_DIR-NOTFOUND
-- HDF5_DEFINITIONS: -DH5_BUILT_AS_DYNAMIC_LIB
-- HDF5_INCLUDE_DIRS: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/include
-- HDF5_LIBRARIES: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5_cpp.lib;C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5.lib
-- HDF5_HL_LIBRARIES:
-- HDF5_CXX_DEFINITIONS:
-- HDF5_CXX_INCLUDE_DIR: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/include
-- HDF5_CXX_INCLUDE_DIRS: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/include
-- HDF5_CXX_LIBRARY:
-- HDF5_CXX_LIBRARIES: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5_cpp.lib;C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5.lib
-- HDF5_CXX_HL_LIBRARY:
-- HDF5_CXX_HL_LIBRARIES:
-- HDF5_C_DEFINITIONS:
-- HDF5_C_INCLUDE_DIR: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/include
-- HDF5_C_INCLUDE_DIRS: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/include
-- HDF5_C_LIBRARY:
-- HDF5_C_LIBRARIES: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5.lib
-- HDF5_C_HL_LIBRARY:
-- HDF5_C_HL_LIBRARIES:
Note that I have no problems with ITK 4.13.1. (I cannot try with ITK 5.0 as https://github.com/InsightSoftwareConsortium/ITK/pull/1165 wasn't merged yet).
I agree with @Neumann-A that ITK really should use the targets when they exist. Sadly, I have no idea on how to do this for ITK.
I agree with @Neumann-A that ITK really should use the hdf5::hdf5 targets, certainly from CMake 3.10 when some things were fixed in FindHDF5.cmake. Sadly, I have no idea on how to do this for ITK.
I see this was discussed here https://github.com/InsightSoftwareConsortium/ITK/pull/1696#issuecomment-624791166
CMake 3.19.0 introduced hdf5::hdf5
etc targets, not called the same as the HDF5 config variables. See this discussion for my current understanding of naming.
Description
Linker error due to missing HDF5 symbols
Steps to Reproduce
Clone https://github.com/Neumann-A/vcpkg/tree/update_itk_51 just run (after bootstrapping vcpkg of course) `./vcpkg.exe install vtk[vtkm,python,qt,paraview,atlmfc] itk[vtk,python]
`
Versions
5.1
Environment
vcpkg/windows
Additional Information
config-x64-windows-dbg-out.log install-x64-windows-dbg-out.log
Additional Information
<removed mentioned in #1696 keep focus here on related issue>
Probably related to: https://github.com/InsightSoftwareConsortium/ITK/blob/7900a8b6d63ec8201405eff3b46c8d2a4e563c45/CMake/ITKModuleMacros.cmake#L160-L168 and https://github.com/InsightSoftwareConsortium/ITK/blob/7900a8b6d63ec8201405eff3b46c8d2a4e563c45/Modules/IO/HDF5/CMakeLists.txt#L2
The following is also a very bad idea if your
_LIBRARIES
are not all targets (due to optimized/debug keywords): https://github.com/InsightSoftwareConsortium/ITK/blob/7900a8b6d63ec8201405eff3b46c8d2a4e563c45/CMake/ITKModuleMacros.cmake#L166If it is all targets probably rename it to
_TARGETS
instead