Skip to content

build error for python bindings with opencv_contrib modules #6016

@avtomaton

Description

@avtomaton

Build from latest version (1cd3c6f) with -DOPENCV_EXTRA_MODULES_PATH=<path to my contrib modules> produces the following error:

In file included from /home/avtomaton/arbeit/sdk/cxx/opencv/build/modules/python2/pyopencv_generated_include.h:11:0,
from /home/avtomaton/arbeit/sdk/cxx/opencv/modules/python/src2/cv2.cpp:12:
/home/avtomaton/arbeit/sdk/cxx/opencv_contrib/modules/hdf/include/opencv2/hdf/hdf5.hpp:40:18: fatal error: hdf5.h: No such file or directory

I attached makefile output for this error. It seems that for python2 and python3 modules there are no include paths for HDF5, i. e. dirty hardcoding

find_package(HDF5)
include_directories(${HDF5_INCLUDE_DIRS})

into modules/python/common.cmake solves the problem. I believe that it is not nice solution, that's why I don't attach pull request.

make-verbose.txt

Activity

alalek

alalek commented on Jan 27, 2016

@alalek
Member

Thanks for report!
Public includes of modules should not depend on external 3rdparty libraries. Violation of this rule provides this problem.
Line with #include <hdf5.h> must gone into internal implementation.

auroua

auroua commented on Jun 5, 2016

@auroua

I have encountered exactly the same error in ubuntu 16.04, and have solved the problem using @avtomaton 's method

cmdelatorre

cmdelatorre commented on Jun 26, 2016

@cmdelatorre

I have encountered exactly the same error with version 3.1.0 in Ubuntu 15.10, and have solved the problem using @avtomaton 's method.

Yaffa1607

Yaffa1607 commented on Sep 13, 2016

@Yaffa1607

What steps do I have to repeat after adding these lines to common.cmake?

rtylecek

rtylecek commented on Oct 5, 2016

@rtylecek

I just run make once again and it compiled (U16.04).

added a commit that references this issue on Dec 13, 2016
added a commit that references this issue on Mar 8, 2017
YuehChuan

YuehChuan commented on Apr 16, 2017

@YuehChuan

Works charm on ubuntu16.04.2 with ROS kinetic, thanks 😄

RamitPahwa

RamitPahwa commented on May 7, 2017

@RamitPahwa

Where exactly do i need to add these lines ??
I am new to the area and not able to navigate to the common.cmake??
Please point me to the right direction.

kvmanohar22

kvmanohar22 commented on May 22, 2017

@kvmanohar22

@Ramit-Pahwa that file is located at <OpenCV_DIR>/modules/python

NickCrews

NickCrews commented on Jun 13, 2017

@NickCrews

@Ramit-Pahwa And I added them on like the 3rd line of the file, so that

# This file is included from a subdirectory
set(PYTHON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../")

ocv_add_module(${MODULE_NAME} BINDINGS)

became

# This file is included from a subdirectory
set(PYTHON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../")

find_package(HDF5)
include_directories(${HDF5_INCLUDE_DIRS})

ocv_add_module(${MODULE_NAME} BINDINGS)

And this worked for me, I only had to run make again (Ubuntu 16.10)

Sreekiranar

Sreekiranar commented on Sep 17, 2018

@Sreekiranar

Worked like a charm. Thanks a lot !! @avtomaton

pravin382

pravin382 commented on Nov 1, 2018

@pravin382

Worked for me, thanks

DronPascal

DronPascal commented on Apr 19, 2020

@DronPascal

I made: $ sudo apt-get install -y libhdf5-dev
And it worked for me!

There's all that u need to QT and OpenCV if u need:
$ sudo apt install build-essential perl python git libx11-xcb-dev libxcb-composite0-dev libxcb-cursor-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-present-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-xkb-dev libxcb-xtest0-dev libxcb1-dev flex bison gperf libicu-dev libxslt-dev ruby libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libdbus-1-dev libfontconfig1-dev libcap-dev libxtst-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libxss-dev libegl1-mesa-dev gperf bison libasound2-dev make cmake libgl1-mesa-dev libglu1-mesa-dev build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev ffmpeg libharfbuzz-dev libglib2.0-dev libpcre2-dev libgstreamer1.0-dev gstreamer1.0-tools gstreamer1.0-plugins-ugly gstreamer1.0-plugins-good gstreamer1.0-plugins-base gstreamer1.0-plugins-bad libgstreamer-plugins-base1.0-dev libdlib-dev libharfbuzz-dev libpcre3-dev libudev-dev libinput-dev libxcb-xinerama0-dev libxcb-xinerama0 libgdk3.0-cil-dev libgtk-3-dev libglib2.0-dev libglib2.0-cil-dev libglib3.0-cil-dev libegl1-mesa-dev libgles2-mesa-dev perl6 bison flex gperf python libdc1394-22-dev libdc1394-utils valgrind libhdf5-devsudo

aismai01

aismai01 commented on May 11, 2020

@aismai01

does anyone know by any chance if the procedure to install it is the same on a Raspberry Pi 3. I got the same error and I followed the recommendation that @avtomaton made but it didn't work

Unlicensed-driver-ljx

Unlicensed-driver-ljx commented on Aug 9, 2023

@Unlicensed-driver-ljx

home/nvidia/opencv/opencv-3.4.5/build/modules/python_bindings_generator/pyopencv_generated_include.h:14:10: fatal error: opencv2/hdf/hdf5.hpp: No such file or directory
14 | #include "opencv2/hdf/hdf5.hpp"
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/build.make:63: modules/python2/CMakeFiles/opencv_python2.dir//src2/cv2.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:6674: modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/nvidia/opencv/opencv-3.4.5/modules/python/src2/cv2.cpp:31:
/home/nvidia/opencv/opencv-3.4.5/build/modules/python_bindings_generator/pyopencv_generated_include.h:14:10: fatal error: opencv2/hdf/hdf5.hpp: No such file or directory
14 | #include "opencv2/hdf/hdf5.hpp"
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/build.make:63: modules/python3/CMakeFiles/opencv_python3.dir/
/src2/cv2.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:6719: modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
在ubutnu20上面编译opencv3.4.5,硬件设备jetson nx报错,这个该如何解决?呼叫全球大佬支援

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @auroua@cmdelatorre@alalek@avtomaton@YuehChuan

        Issue actions

          build error for python bindings with opencv_contrib modules · Issue #6016 · opencv/opencv