Description
System Information
OpenCV version: 4.7.0 (also tested with 4.10.0)
Operating System: Ubuntu 22.04 (also tested with 24.04)
Compiler version: GCC 11.4.0 (also tested with 13.3.0)
CMake version: 3.22 (also tested with 3.28)
Detailed description
Dear OpenCV community,
When compiling opencv with opencv_contrib with the cmake flag -DHDF5_PREFER_PARALLEL=ON
and the compilation reaches the opencv_hdf
module, the compilation fails with the following error:
In file included from /usr/include/hdf5/openmpi/hdf5.h:22,
from /usr/local/src/opencv_contrib/modules/hdf/src/hdf5.cpp:37:
/usr/include/hdf5/openmpi/H5public.h:63:13: fatal error: mpi.h: No such file or directory
63 | # include <mpi.h>
| ^~~~~~~
When changing the cmake flag to -DHDF5_PREFER_PARALLEL=OFF
, then the compilation of the opencv_hdf
module succeeds.
libopenmpi-dev is installed on my system and I successfully compiled a test program on my system that includes the mpi.h
file located on my system at /usr/lib/x86_64-linux-gnu/openmpi/include
(albeit with the mpic++
script, not simply the gcc/g++ compiler), so the issue does not seem to lie with the file not existing on my system.
I also tried to edit the CMakeLists.txt file in opencv_contrib/modules/hdf/CMakeLists.txt
and add the directory where mpi.h
lies to the HDF5_INCLUDE_DIRS
variable, but this also did not help with the compilation; still the same error as above.
How should I solve this issue? 😄
Steps to reproduce
wget https://github.com/opencv/opencv/archive/refs/tags/4.10.0.tar.gz && \
tar -xf 4.10.0.tar.gz && \
rm 4.10.0.tar.gz && \
mv opencv-4.10.0 opencv && \
wget https://github.com/opencv/opencv_contrib/archive/refs/tags/4.10.0.tar.gz && \
tar -xf 4.10.0.tar.gz && \
rm 4.10.0.tar.gz && \
mv opencv_contrib-4.10.0 opencv_contrib && \
cd opencv && \
mkdir build-release && \
cd build-release && \
cmake .. -DCMAKE_BUILD_TYPE=Release -DHDF5_PREFER_PARELLEL=ON -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" && \
make -j6 opencv_hdf
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)