Open LiShuaixin opened 2 years ago
As a workaround you could disable hdf module (refer to OpenCV build documentation): cmake ... -DBUILD_opencv_hdf=OFF
I'm sorry if the comment is wrong.
I think you maybe installed only parallel hdf5(libhdf5-mpich-dev) and not installed serial hdf5(libhdf5-dev). libhdf5-mpich-dev depends MPI library.
kmtr@kmtr:~/work/build$ LANG=C apt search libhdf5 | grep "\-dev"
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libhdf5-dev/impish 1.10.6+repack-5 amd64
libhdf5-mpi-dev/impish 1.10.6+repack-5 amd64
libhdf5-mpich-dev/impish,now 1.10.6+repack-5 amd64 [installed]
libhdf5-openmpi-dev/impish 1.10.6+repack-5 amd64
Currently contrib-hdf5 module supports only libhdf5-dev . It doesn't depend MPI Library.
So that to compile contrib-hdf5 with libhdf5-mpich-dev is failed with missing MPI library. (Maybe same trouble with libhdf5-openmpi-dev is happend too).
There are 2 extra options.
1) sudo apt install libhdf5-dev
to install serial hdf5.
CMake gives priority to libhdf5-dev than libhdf5-mpich-dev.
2) if you want to use parallel hdf5, CMakefile should be changed.
My test is not too enough to pull reqeust, which is only to run opencv_test_hdf and to check dependency library.
kmtr@kmtr:~/work/opencv_contrib$ git --no-pager diff
diff --git a/modules/hdf/CMakeLists.txt b/modules/hdf/CMakeLists.txt
index 2a1ae68b..2c0bb4a5 100644
--- a/modules/hdf/CMakeLists.txt
+++ b/modules/hdf/CMakeLists.txt
@@ -25,11 +25,28 @@ if(NOT HDF5_FOUND)
ocv_module_disable(hdf) # no return
endif()
+set(HDF5_ADD_LIBRARIES "")
+set(HDF5_ADD_INCLUDE_DIRS "")
+
+if(HDF5_IS_PARALLEL)
+ status("HDF5: Parallel")
+ find_package(MPI)
+
+ if(NOT MPI_FOUND)
+ status("HDF5_IS_PARALLEL is TRUE, but MPI is NOT FOUND -> hdf is disabled,")
+ ocv_module_disable(hdf) # no return
+ endif()
+ set(HDF5_ADD_LIBRARIES ${MPI_CXX_LIBRARIES})
+ set(HDF5_ADD_INCLUDE_DIRS ${MPI_CXX_INCLUDE_DIRS})
+else()
+ status("HDF5: Serial")
+endif()
+
set(HAVE_HDF5 1)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Winvalid-offsetof)
set(the_description "Hierarchical Data Format I/O")
ocv_define_module(hdf opencv_core WRAP python)
-ocv_target_link_libraries(${the_module} ${HDF5_LIBRARIES})
-ocv_include_directories(${HDF5_INCLUDE_DIRS})
+ocv_target_link_libraries(${the_module} ${HDF5_LIBRARIES} ${HDF5_ADD_LIBRARIES})
+ocv_include_directories(${HDF5_INCLUDE_DIRS} ${HDF5_ADD_INCLUDE_DIRS})
kmtr@kmtr:~/work/build$ ldd bin/opencv_test_hdf | grep mpi
libhdf5_mpich.so.103 => /lib/x86_64-linux-gnu/libhdf5_mpich.so.103 (0x00007f200bd1e000)
libmpi.so.40 => /lib/x86_64-linux-gnu/libmpi.so.40 (0x00007f200bbf3000)
libmpich.so.12 => /lib/x86_64-linux-gnu/libmpich.so.12 (0x00007f200b127000)
Make sure you check out the same tags for the opencv and opencv_contrib modules. For example do: git checkout tags/4.5.0
in both opencv folder and opencv_contrib folder.
System information (version)
Detailed description
When compiled with opencv_contrib, it failed as:
I can
make
smoothly without contrib-module. It seems like an issue with hdf5 and openmpi.... How should I fix the issue? Many thanks!!!!