Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to link against H5Z-ZFP on Windows #130

Open
kerim371 opened this issue Dec 11, 2023 · 4 comments
Open

Failed to link against H5Z-ZFP on Windows #130

kerim371 opened this issue Dec 11, 2023 · 4 comments

Comments

@kerim371
Copy link

Hi,

I just tried to install and link aganist H5Z-ZFP with cmake but it gives configuration error:

CMake Error at C:/Qt/Tools/CMake_64/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find H5Z_ZFP: missing: H5Z_ZFP_LIBRARY H5Z_ZFP_INCLUDE_DIR (found
  C:/Users/user/dev/H5Z-ZFP-install/lib/cmake/h5z_zfp/h5z_zfp-config.cmake
  (found version "1.1.1"))

and it seems that h5z_zfp-config.cmake doesn't look for .dll libraries.
My content of this file:

# h5z_zfp-config.cmake
# --------------------
#
# Finds the H5Z_ZFP library, specify the starting search path in H5Z_ZFP_ROOT
#
# Static vs. shared
# ----------------- 
# To make use of the static library instead of the shared one, one needs
# to set the variable H5Z_ZFP_USE_STATIC_LIBS to ON before calling find_package.
# Example:
#   set(H5Z_ZFP_USE_STATIC_LIBS ON)
#   find_package(H5Z_ZFP REQUIRED CONFIG)
#
# This will define the following variables:
#
#   H5Z_ZFP_FOUND       - True if the system has the H5Z_ZFP library.
#   H5Z_ZFP_WITH_OPENMP - True if the zfp library has been built with OpenMP support.
#
# and the following imported targets:
#
#   h5z_zfp::h5z_zfp - The H5Z_ZFP library.

find_path(H5Z_ZFP_INCLUDE_DIR NAMES H5Zzfp.h DOC "H5Z_ZFP include directory")
if(H5Z_ZFP_USE_STATIC_LIBS)
  find_library(H5Z_ZFP_LIBRARY NAMES libh5zzfp.a DOC "H5Z_ZFP library")
else()
  find_library(H5Z_ZFP_LIBRARY NAMES libh5zzfp.so HINTS $ENV{H5Z_ZFP_ROOT}/plugin DOC "H5Z_ZFP library")
endif()

include(FindPackageHandleStandardArgs)
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
find_package_handle_standard_args(H5Z_ZFP
  FOUND_VAR H5Z_ZFP_FOUND
  REQUIRED_VARS H5Z_ZFP_LIBRARY H5Z_ZFP_INCLUDE_DIR
  CONFIG_MODE
)

if(H5Z_ZFP_FOUND)
  set(HDF5_USE_STATIC_LIBRARIES ${H5Z_ZFP_USE_STATIC_LIBS})
  find_package(HDF5 MODULE REQUIRED COMPONENTS C)
  find_package(ZFP REQUIRED CONFIG)
  if(H5Z_ZFP_USE_STATIC_LIBS)
    add_library(h5z_zfp::h5z_zfp STATIC IMPORTED)
  else()
    add_library(h5z_zfp::h5z_zfp SHARED IMPORTED)
  endif()
  set_target_properties(h5z_zfp::h5z_zfp PROPERTIES
    IMPORTED_LOCATION "${H5Z_ZFP_LIBRARY}"
    INTERFACE_INCLUDE_DIRECTORIES "${H5Z_ZFP_INCLUDE_DIR}"
    INTERFACE_LINK_LIBRARIES "zfp::zfp;${HDF5_LIBRARIES}"
    LINK_LIBRARIES "zfp::zfp;${HDF5_LIBRARIES}"
  )
  set(H5Z_ZFP_WITH_OPENMP ${ZFP_WITH_OPENMP})
endif()

mark_as_advanced(
  H5Z_ZFP_INCLUDE_DIR
  H5Z_ZFP_LIBRARY
)

H5Z-ZFP git tag: v1.1.1

@brtnfld
Copy link
Collaborator

brtnfld commented Dec 11, 2023

Did you do this for your application?
https://h5z-zfp.readthedocs.io/en/latest/installation.html#including-h5z-zfp-filter-in-a-cmake-project

@jwsblokland
Copy link
Contributor

Hello @kerim371 and @brtnfld,

Looking at the latest version h5z_zfp-config.cmake it is correct Windows is not properly supported. At least not MSVC. Since the static and shared version of the filter are stored in different directory it should be straightforward to implement support for Windows.

At the time when I converted the existing build system (Unix/Linux based) to a CMake build system I did not consider the possibility to build the filter on Windows. Nevertheless, I am happy to read that you want to do this. If desired I can take a look the problem.

@kerim371
Copy link
Author

Did you do this for your application? https://h5z-zfp.readthedocs.io/en/latest/installation.html#including-h5z-zfp-filter-in-a-cmake-project

Yes I tried this.

@jwsblokland it would be great to imrove CMake config so that it could be properly linked with CMake on Windows.
And I can tell you that if I link it directly to my app then it works:

target_link_libraries(FastIO PUBLIC "C:\\Users\\user\\dev\\H5Z-ZFP-install\\lib\\h5zzfp.lib")
target_link_libraries(FastIO PUBLIC "C:\\Users\\user\\dev\\zfp-install\\lib\\zfp.lib")

So there is only a little defect with CMake config.

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 12, 2023

Looks like the config file didn't get updated to a more general method. We have done this for all the config files in hdf5/hdf4. Just need to use the CMake suggestions for creating the .in file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants