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

HDF5_LIB_INFIX doesn't work with DLL #4440

Closed
Nekto89 opened this issue Apr 24, 2024 · 5 comments
Closed

HDF5_LIB_INFIX doesn't work with DLL #4440

Nekto89 opened this issue Apr 24, 2024 · 5 comments
Assignees
Labels
Component - Build CMake, Autotools Priority - 2. Medium ⏹ It would be nice to have this in the next release Type - Bug Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub

Comments

@Nekto89
Copy link

Nekto89 commented Apr 24, 2024

Describe the bug
I want to be able to change name of generated dll files. I saw that there is HDF5_LIB_INFIX. But it seems that it doesn't work properly with dynamic libraries. Name of cmake target is changed so the name of preprocessor definition that is injected automatically by CMake is also changed. But hdf5 code still expects old names. Example:
I've used HDF5_LIB_INFIX=_1.14.3.
CMake changed name of project to hdf5_1.14.3-shared and injected hdf5_1_14_3_shared_EXPORTS

#if defined(hdf5_shared_EXPORTS)

This leads to lots of errors

2>C:\Users\Nekto\.conan2\p\b\hdf55bbae7f6b7711\b\src\src\H5timer.c(93,1): warning C4273: 'H5_bandwidth': inconsistent dll linkage
2>C:\Users\Nekto\.conan2\p\b\hdf55bbae7f6b7711\b\src\src\H5private.h(557,13): message : see previous definition of 'H5_bandwidth' (compiling source file C:\Users\Nekto\.conan2\p\b\hdf55bbae7f6b7711\b\src\src\H5timer.c)

Expected behavior
There are no errors, dll has different name.

Platform (please complete the following information)

  • HDF5 version (if building from a maintenance branch, please include the commit hash): 1.14.3
  • OS and version: Windows 11
  • Compiler and version: VS2022 Update 9 (17.9.6)
  • Build system (e.g. CMake, Autotools) and version: CMake 3.29.2
  • Any configure options you specified
# Variables
set(CMAKE_CXX_STANDARD "11" CACHE STRING "Variable CMAKE_CXX_STANDARD conan-toolchain defined")
set(HDF5_EXTERNALLY_CONFIGURED ON CACHE BOOL "Variable HDF5_EXTERNALLY_CONFIGURED conan-toolchain defined")
set(HDF5_EXTERNAL_LIB_PREFIX "" CACHE STRING "Variable HDF5_EXTERNAL_LIB_PREFIX conan-toolchain defined")
set(HDF5_LIB_INFIX "_1.14.3" CACHE STRING "Variable HDF5_LIB_INFIX conan-toolchain defined")
set(HDF5_USE_FOLDERS OFF CACHE BOOL "Variable HDF5_USE_FOLDERS conan-toolchain defined")
set(HDF5_NO_PACKAGES ON CACHE BOOL "Variable HDF5_NO_PACKAGES conan-toolchain defined")
set(ONLY_SHARED_LIBS "True" CACHE STRING "Variable ONLY_SHARED_LIBS conan-toolchain defined")
set(BUILD_STATIC_LIBS OFF CACHE BOOL "Variable BUILD_STATIC_LIBS conan-toolchain defined")
set(BUILD_STATIC_EXECS OFF CACHE BOOL "Variable BUILD_STATIC_EXECS conan-toolchain defined")
set(HDF5_ENABLE_COVERAGE OFF CACHE BOOL "Variable HDF5_ENABLE_COVERAGE conan-toolchain defined")
set(HDF5_ENABLE_USING_MEMCHECKER OFF CACHE BOOL "Variable HDF5_ENABLE_USING_MEMCHECKER conan-toolchain defined")
set(HDF5_MEMORY_ALLOC_SANITY_CHECK OFF CACHE BOOL "Variable HDF5_MEMORY_ALLOC_SANITY_CHECK conan-toolchain defined")
set(HDF5_ENABLE_PREADWRITE ON CACHE BOOL "Variable HDF5_ENABLE_PREADWRITE conan-toolchain defined")
set(HDF5_ENABLE_DEPRECATED_SYMBOLS ON CACHE BOOL "Variable HDF5_ENABLE_DEPRECATED_SYMBOLS conan-toolchain defined")
set(HDF5_BUILD_GENERATORS OFF CACHE BOOL "Variable HDF5_BUILD_GENERATORS conan-toolchain defined")
set(HDF5_ENABLE_TRACE OFF CACHE BOOL "Variable HDF5_ENABLE_TRACE conan-toolchain defined")
set(HDF5_ENABLE_PARALLEL "False" CACHE STRING "Variable HDF5_ENABLE_PARALLEL conan-toolchain defined")
set(HDF5_ENABLE_Z_LIB_SUPPORT "True" CACHE STRING "Variable HDF5_ENABLE_Z_LIB_SUPPORT conan-toolchain defined")
set(HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "Variable HDF5_ENABLE_SZIP_SUPPORT conan-toolchain defined")
set(HDF5_ENABLE_SZIP_ENCODING OFF CACHE BOOL "Variable HDF5_ENABLE_SZIP_ENCODING conan-toolchain defined")
set(HDF5_PACKAGE_EXTLIBS OFF CACHE BOOL "Variable HDF5_PACKAGE_EXTLIBS conan-toolchain defined")
set(HDF5_ENABLE_THREADSAFE "True" CACHE STRING "Variable HDF5_ENABLE_THREADSAFE conan-toolchain defined")
set(HDF5_ENABLE_DEBUG_APIS OFF CACHE BOOL "Variable HDF5_ENABLE_DEBUG_APIS conan-toolchain defined")
set(BUILD_TESTING OFF CACHE BOOL "Variable BUILD_TESTING conan-toolchain defined")
set(HDF5_INSTALL_INCLUDE_DIR "include/hdf5" CACHE STRING "Variable HDF5_INSTALL_INCLUDE_DIR conan-toolchain defined")
set(HDF5_BUILD_TOOLS OFF CACHE BOOL "Variable HDF5_BUILD_TOOLS conan-toolchain defined")
set(HDF5_BUILD_UTILS OFF CACHE BOOL "Variable HDF5_BUILD_UTILS conan-toolchain defined")
set(HDF5_BUILD_EXAMPLES OFF CACHE BOOL "Variable HDF5_BUILD_EXAMPLES conan-toolchain defined")
set(HDF5_BUILD_HL_LIB "False" CACHE STRING "Variable HDF5_BUILD_HL_LIB conan-toolchain defined")
set(HDF5_BUILD_FORTRAN OFF CACHE BOOL "Variable HDF5_BUILD_FORTRAN conan-toolchain defined")
set(HDF5_BUILD_CPP_LIB "False" CACHE STRING "Variable HDF5_BUILD_CPP_LIB conan-toolchain defined")
set(HDF5_BUILD_JAVA OFF CACHE BOOL "Variable HDF5_BUILD_JAVA conan-toolchain defined")
set(ALLOW_UNSUPPORTED "False" CACHE STRING "Variable ALLOW_UNSUPPORTED conan-toolchain defined")
  • MPI library and version (parallel HDF5)

Additional context
Add any other context about the problem here.

@Nekto89
Copy link
Author

Nekto89 commented Apr 25, 2024

Maybe CMake targets in hdf5 should hardcode DEFINE_SYMBOL property for shared libraries so that it doesn't depend on target name?
https://cmake.org/cmake/help/latest/prop_tgt/DEFINE_SYMBOL.html

@derobins derobins added Priority - 2. Medium ⏹ It would be nice to have this in the next release Component - Build CMake, Autotools Type - Bug Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub labels Apr 25, 2024
@byrnHDF
Copy link
Contributor

byrnHDF commented May 14, 2024

The problem seems to be that the addition of HDF5_LIB_INFIX should not have modified target names and instead only changed file names.

@byrnHDF
Copy link
Contributor

byrnHDF commented May 14, 2024

Looking at the code, just moving the HDF5_LIB_INFIX from the CORENAME defines to the LIB_NAME defines would solve the problem.

@byrnHDF
Copy link
Contributor

byrnHDF commented May 14, 2024

The PackageConfig uses of CORENAME would likely need to be changed to use the LIB_NAME defines as well

@byrnHDF
Copy link
Contributor

byrnHDF commented May 20, 2024

Closed by #4500

@byrnHDF byrnHDF self-assigned this May 20, 2024
@byrnHDF byrnHDF closed this as completed Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Build CMake, Autotools Priority - 2. Medium ⏹ It would be nice to have this in the next release Type - Bug Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub
Projects
None yet
Development

No branches or pull requests

3 participants