jorgensd / dolfinx_mpc

Extension for dolfinx to handle multi-point constraints.
https://jorgensd.github.io/dolfinx_mpc/
MIT License
30 stars 12 forks source link

Compiling v0.4.1: Trouble with hdf5 #18

Closed welahi closed 1 year ago

welahi commented 2 years ago

I set up an virtual environment via conda and installed dolfinx 0.4.1 there. While having activated that environment, I was trying to compile dolfinx_mpc (the tagged commit "v0.4.1"). I'm on Ubuntu 21.04 (I know, I should update...)

At first, cmake complained about not being able to find "FindHDF5.cmake". I had to manually add the system's cmake-installation's module path again: set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/share/cmake-3.18/Modules/"). I realize that is maybe an issue because of conda. Is this the case? Are there any other workarounds?

Anyway, that problem is solved now, but now I think the problem is that some component needs the static hdf5-library (libhdf5_hl.a), while conda install h5py only installs the dynamic library (libhdf5_hl.so, I've confirmed the existence of this file). Below are the error messages. Did I understand the issue correctly? Because if yes, I don't think there's much the maintainers can do, it's a problem caused by using conda, and I probably need to compile a virtualenv-friendly hdf5/h5py...

[...]
-- Adding boost_filesystem dependencies: headers
-- Adding /usr/lib/python3/dist-packages/basix to Basix search hints
x86_64-conda-linux-gnu-cc: error: .../condaenvs/fenicsenv/lib/libhdf5_hl.a: No such file or directory
x86_64-conda-linux-gnu-cc: error: .../condaenvs/fenicsenv/lib/libhdf5.a: No such file or directory
-- HDF5 C compiler wrapper is unable to compile a minimal HDF5 program.
CMake Warning at /usr/share/cmake-3.18/Modules/FindHDF5.cmake:726 (message):
  HDF5 found for language C is not parallel but previously found language is
  parallel.
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  .../condaenvs/fenicsenv/lib/cmake/dolfinx/DOLFINXConfig.cmake:76 (find_dependency)
  CMakeLists.txt:93 (find_package)

-- HDF5_DIR: HDF5_DIR-NOTFOUND
-- HDF5_DEFINITIONS: 
-- HDF5_INCLUDE_DIRS: .../condaenvs/fenicsenv/include
-- HDF5_LIBRARIES: .../condaenvs/fenicsenv/lib/libhdf5.so
-- HDF5_HL_LIBRARIES: 
-- HDF5_C_DEFINITIONS: 
-- HDF5_C_INCLUDE_DIR: .../condaenvs/fenicsenv/include
-- HDF5_C_INCLUDE_DIRS: .../condaenvs/fenicsenv/include
-- HDF5_C_LIBRARY: 
-- HDF5_C_LIBRARIES: .../condaenvs/fenicsenv/lib/libhdf5.so
-- HDF5_C_HL_LIBRARY: 
-- HDF5_C_HL_LIBRARIES: 
-- Found MPI_C: .../condaenvs/fenicsenv/lib/libmpi.so (found suitable version "4.0", minimum required is "3") 
-- Found MPI_CXX: .../condaenvs/fenicsenv/lib/libmpicxx.so (found suitable version "4.0", minimum required is "3") 
-- Found MPI: TRUE (found suitable version "4.0", minimum required is "3")  
-- The following features have been enabled:

 * BUILD_SHARED_LIBS, Build DOLFINX_MPC with shared libraries.
 * CMAKE_INSTALL_RPATH_USE_LINK_PATH, Add paths to linker search and installed rpath.

-- The following OPTIONAL packages have been found:

 * Python3

-- The following REQUIRED packages have been found:

 * PythonInterp (required version >= 3)
 * boost_chrono (required version == 1.74.0)
 * boost_timer (required version == 1.74.0)
 * boost_headers (required version == 1.74.0)
 * boost_filesystem (required version == 1.74.0)
 * DOLFINX (required version >= 0.4.1), New generation Dynamic Object-oriented Library for - FINite element computation, <https://github.com/FEniCS/dolfinx>
   Main dependency of library
 * Basix (required version >= 0.4.1)
 * MPI (required version >= 3)
 * PkgConfig
 * PETSc, Portable, Extensible Toolkit for Scientific Computation (PETSc), <https://www.mcs.anl.gov/petsc/>
   PETSc linear algebra backend

CMake Warning at CMakeLists.txt:142 (find_package): ### !!! <--- I added some lines, it's your line 137!
  By not providing "Findhdf5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "hdf5", but
  CMake did not find one.

  Could not find a package configuration file provided by "hdf5" with any of
  the following names:

    hdf5Config.cmake
    hdf5-config.cmake

  Add the installation prefix of "hdf5" to CMAKE_PREFIX_PATH or set
  "hdf5_DIR" to a directory containing one of the above files.  If "hdf5"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring done
CMake Error at CMakeLists.txt:144 (add_library):
  Target "dolfinx_mpc" links to target "hdf5::hdf5" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

CMake Error at CMakeLists.txt:144 (add_library):
  Target "dolfinx_mpc" links to target "hdf5::hdf5" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.
jorgensd commented 2 years ago

As I do not use conda, I simply do not know where it places the hdf5 library that is used by DOLFINx. I suspect that:

: set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/share/cmake-3.18/Modules/"). is not correct hdf5 library, as the conda library (https://github.com/conda-forge/fenics-dolfinx-feedstock/tree/main/recpe) depends on hdf5 installed with conda.

welahi commented 2 years ago

Mmh I think in CMAKE_MODULE_PATH there is only the CMake-module FindHDF5.cmake, which searches the system for any hdf5-libraries, and not the library itself. The other outputs (e.g. HDF5_LIBRARIES: .../condaenvs/fenicsenv/lib/libhdf5.so) suggest that indeed the HDF5-library of conda is used.

You mentioned on the fenicsx-discourse that dolfinx_mpc isn't even using the HDF5-C-lib and that you're using only h5py, right? Do you know which dependency may be causing this error?

In any case, this issue is not all that important. I think on the long term I just can't avoid docker anyway, so there's that.

jorgensd commented 2 years ago

To me, from the partial output you are supplying, it looksl like it is DOLFINx: https://github.com/FEniCS/dolfinx/blob/162330e5563a8b79ecc61f0756c69a585e4a6f7f/cpp/cmake/templates/DOLFINXConfig.cmake.in#L39-L57 as this was the last output before the error:

-- Adding /usr/lib/python3/dist-packages/basix to Basix search hints
x86_64-conda-linux-gnu-cc: error: .../condaenvs/fenicsenv/lib/libhdf5_hl.a: No such file or directory
x86_64-conda-linux-gnu-cc: error: .../condaenvs/fenicsenv/lib/libhdf5.a: No such file or directory
-- HDF5 C compiler wrapper is unable to compile a minimal HDF5 program.
CMake Warning at /usr/share/cmake-3.18/Modules/FindHDF5.cmake:726 (message):
  HDF5 found for language C is not parallel but previously found language is
  parallel.
SarveshVIT commented 1 year ago

Hi, I am also facing a similar issue

``

-- Asking Python module FFCX for location of UFC...
-- Found MPI_C: /home/sarvesh/anaconda3/envs/fenicsx-env/lib/libmpi.so (found version "4.0")
-- Found MPI_CXX: /home/sarvesh/anaconda3/envs/fenicsx-env/lib/libmpicxx.so (found version "4.0")
-- Found MPI: TRUE (found version "4.0")
-- Found Boost 1.74.0 at /home/sarvesh/anaconda3/envs/fenicsx-env/lib/cmake/Boost-1.74.0
--   Requested configuration: QUIET REQUIRED COMPONENTS timer;filesystem
-- Found boost_headers 1.74.0 at /home/sarvesh/anaconda3/envs/fenicsx-env/lib/cmake/boost_headers-1.74.0-- Found boost_timer 1.74.0 at /home/sarvesh/anaconda3/envs/fenicsx-env/lib/cmake/boost_timer-1.74.0
--   [x] libboost_timer.so.1.74.0
-- Adding boost_timer dependencies: chrono;headers
-- Found boost_chrono 1.74.0 at /home/sarvesh/anaconda3/envs/fenicsx-env/lib/cmake/boost_chrono-1.74.0
--   [x] libboost_chrono.so.1.74.0
-- Adding boost_chrono dependencies: headers
-- Found boost_filesystem 1.74.0 at /home/sarvesh/anaconda3/envs/fenicsx-env/lib/cmake/boost_filesystem-1.74.0
--   [x] libboost_filesystem.so.1.74.0
-- Adding boost_filesystem dependencies: headers
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- HDF5_DIR: HDF5_DIR-NOTFOUND
-- HDF5_DEFINITIONS: -DNDEBUG;-D_FORTIFY_SOURCE=2
-- HDF5_INCLUDE_DIRS: /home/sarvesh/anaconda3/envs/fenicsx-env/include
-- HDF5_LIBRARIES: /home/sarvesh/anaconda3/envs/fenicsx-env/lib/libhdf5.so;/home/sarvesh/anaconda3/envs/fenicsx-env/lib/libcrypto.so;/home/sarvesh/anaconda3/envs/fenicsx-env/lib/libcurl.so;/home/sarvesh/anaconda3/envs/fenicsx-env/x86_64-conda-linux-gnu/sysroot/usr/lib/librt.so;/home/sarvesh/anaconda3/envs/fenicsx-env/x86_64-conda-linux-gnu/sysroot/usr/lib/libpthread.so;/home/sarvesh/anaconda3/envs/fenicsx-env/lib/libz.so;/home/sarvesh/anaconda3/envs/fenicsx-env/x86_64-conda-linux-gnu/sysroot/usr/lib/libdl.so;/home/sarvesh/anaconda3/envs/fenicsx-env/x86_64-conda-linux-gnu/sysroot/usr/lib/libm.so
-- HDF5_HL_LIBRARIES:
-- HDF5_C_DEFINITIONS: -DNDEBUG;-D_FORTIFY_SOURCE=2
-- HDF5_C_INCLUDE_DIR:
-- HDF5_C_INCLUDE_DIRS: /home/sarvesh/anaconda3/envs/fenicsx-env/include
-- HDF5_C_LIBRARY:
-- HDF5_C_LIBRARIES: /home/sarvesh/anaconda3/envs/fenicsx-env/lib/libhdf5.so;/home/sarvesh/anaconda3/envs/fenicsx-env/lib/libcrypto.so;/home/sarvesh/anaconda3/envs/fenicsx-env/lib/libcurl.so;/home/sarvesh/anaconda3/envs/fenicsx-env/x86_64-conda-linux-gnu/sysroot/usr/lib/librt.so;/home/sarvesh/anaconda3/envs/fenicsx-env/x86_64-conda-linux-gnu/sysroot/usr/lib/libpthread.so;/home/sarvesh/anaconda3/envs/fenicsx-env/lib/libz.so;/home/sarvesh/anaconda3/envs/fenicsx-env/x86_64-conda-linux-gnu/sysroot/usr/lib/libdl.so;/home/sarvesh/anaconda3/envs/fenicsx-env/x86_64-conda-linux-gnu/sysroot/usr/lib/libm.so
-- HDF5_C_HL_LIBRARY:
-- HDF5_C_HL_LIBRARIES:
-- Found MPI_C: /home/sarvesh/anaconda3/envs/fenicsx-env/lib/libmpi.so (found suitable version "4.0", minimum required is "3")
-- Found MPI_CXX: /home/sarvesh/anaconda3/envs/fenicsx-env/lib/libmpicxx.so (found suitable version "4.0", minimum required is "3")
-- Found MPI: TRUE (found suitable version "4.0", minimum required is "3")
-- The following features have been enabled:

 * BUILD_SHARED_LIBS, Build DOLFINX_MPC with shared libraries.
 * CMAKE_INSTALL_RPATH_USE_LINK_PATH, Add paths to linker search and installed rpath.

-- The following OPTIONAL packages have been found:

 * Python3

-- The following REQUIRED packages have been found:

 * PythonInterp (required version >= 3)
 * boost_chrono (required version == 1.74.0)
 * boost_timer (required version == 1.74.0)
 * boost_headers (required version == 1.74.0)
 * boost_filesystem (required version == 1.74.0)
 * DOLFINX (required version >= 0.5.0), New generation Dynamic Object-oriented Library for - FINite element computation, <https://github.com/FEniCS/dolfinx>
   Main dependency of library
 * Basix (required version >= 0.5.0)
 * MPI (required version >= 3)
 * PkgConfig
 * PETSc, Portable, Extensible Toolkit for Scientific Computation (PETSc), <https://www.mcs.anl.gov/petsc/>
   PETSc linear algebra backend

-- Configuring done
CMake Error at CMakeLists.txt:137 (add_library):
  Target "dolfinx_mpc" links to target "hdf5::hdf5" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

CMake Error at CMakeLists.txt:137 (add_library):
  Target "dolfinx_mpc" links to target "hdf5::hdf5" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

This is my complete error message

jorgensd commented 1 year ago

This looks like an issue with the DOLFINx conda package, or how conda install hdf5. could you try installing hdf5-static from conda forge: https://anaconda.org/conda-forge/hdf5-static

SarveshVIT commented 1 year ago

This looks like an issue with the DOLFINx conda package, or how conda install hdf5. could you try installing hdf5-static from conda forge: https://anaconda.org/conda-forge/hdf5-static

I tried this, but I'm still getting the same error

jorgensd commented 1 year ago

Dolfinx_mpc is now on conda-forge https://anaconda.org/conda-forge/dolfinx_mpc