Hello everyone,
I would like to link the hdf5 library statically, however, I am unable to do it.
I have tried to use the precompiled files, to build the source in debug mode, release mode, using CMake, without using CMake. Nothing works, I always have a list of warnings and errors that begins with
out\build\x64-Debug\LINK : warning LNK4217: symbol ‘isalpha’ defined in ‘libucrt.lib(_ctype.obj)’ is imported by ‘libhdf5_D.lib(H5.obj)’ in function ‘H5_debug_mask’,
and ends with
out\build\x64-Debug\libhdf5_D.lib(H5Clog_trace.obj) : error LNK2001: unresolved external symbol __imp_setbuf
out\build\x64-Debug\libhdf5_D.lib(H5Defl.obj) : error LNK2019: unresolved external symbol __imp__access referenced in function H5D__efl_write
with lots of unresolved symbols in between (Using the release file gives slightly different errors, generally replacing _D with nothing).
My CMake file is comprised of
find_package requires lowcase static or shared
set (LIB_TYPE STATIC) #or SHARED
string(TOLOWER ${LIB_TYPE} SEARCH_TYPE)find_package( HDF5 NAMES hdf5 COMPONENTS C NO_MODULE REQUIRED ${SEARCH_TYPE} )
stores the library path into a variable called hdf5_lib
set (HDF5_LIB ${HDF5_C_${LIB_TYPE}_LIBRARY})
copy required dlls
file( COPY “${CMAKE_SOURCE_DIR}/lib/HDF5-1.12.0-win64/bin/hdf5.dll” DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
configure library
add_library(Hdf5Interface STATIC
hdf5Interface.cpp
)
target_link_libraries( Hdf5Interface PUBLIC ${HDF5_LIB})
If I replace STATIC to SHARED and uncomment the copy line everything works (dynamically). So, can someone help me figuring out what I am doing wrong?