FS#50111 - [opencv] CMake error with HDF5

Attached to Project: Arch Linux
Opened by Leonardo B (leonardo) - Wednesday, 20 July 2016, 14:03 GMT
Last edited by Doug Newgard (Scimmia) - Friday, 30 March 2018, 13:39 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Ray Rashif (schivmeister)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Description:
Updated CMake package (3.6.0-1), and now it bugs when I try to compile OpenCV.
When I downgraded to 3.5.2-2 it got to work again.

The error is:
#################
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
HDF5_hdf5_cpp_LIBRARY
linked by target "opencv_hdf" in directory /home/leonardo/OpenCV/OpenCV3/opencv_contrib/modules/hdf

-- Configuring incomplete, errors occurred!
See also "/home/user/OpenCV/OpenCV3/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/OpenCV/OpenCV3/build/CMakeFiles/CMakeError.log".
#################

Steps to reproduce:

#Download git OpenCV.#

OPTIONS="-DWITH_OPENCL=ON
-DWITH_OPENGL=ON
-DWITH_TBB=ON
-DWITH_XINE=ON
-DWITH_OPENNI=ON
-DWITH_GSTREAMER=OFF
-DBUILD_WITH_DEBUG_INFO=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_EXAMPLES=ON
-DINSTALL_C_EXAMPLES=ON
-DINSTALL_PYTHON_EXAMPLES=ON
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_SKIP_RPATH=ON
-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules
-DCMAKE_INSTALL_PREFIX=/usr/local"

cd build

cmake $OPTIONS ../opencv

make -j7

This task depends upon

Closed by  Doug Newgard (Scimmia)
Friday, 30 March 2018, 13:39 GMT
Reason for closing:  No response
Comment by Leonardo B (leonardo) - Thursday, 28 July 2016, 13:01 GMT
Problem still happens after upgrade to 3.6.1-1.

If I downgrade to 3.5.2-2 there is no problem.
Comment by Leonardo B (leonardo) - Thursday, 28 July 2016, 13:03 GMT
Full log attached.
Comment by Ray Rashif (schivmeister) - Saturday, 30 July 2016, 12:17 GMT
Leonardo, thanks for the report and apologies for the delay in acknowledging/fixing this. It does look a bit odd but I will have a deeper look by the end of the week, if no-one else gets to it before me. Thanks for your patience!
Comment by patrick (potomac) - Sunday, 31 July 2016, 04:15 GMT
I get the same bug, does anyone know if a workaround exists ?

a bug report in upstream may be useful
Comment by AK (Andreaskem) - Sunday, 31 July 2016, 09:20 GMT
While I am not an expert, I looked into this for a few minutes and would like to report what I found.

My first guess is that you have the package hdf5 installed and not hdf5-cpp-fortran. It would probably work with the latter package installed. Your logs suggest that the regular HDF5 C library was found, but not the C++ version.

My second guess is that the following change might have made cmake fail in this scenario:
https://cmake.org/gitweb?p=cmake.git;a=blobdiff;f=Modules/FindHDF5.cmake;h=a81ba13d9df3ae48380436143006c9f2bfe8b794;hp=46c8896eb0325a46b7e4edb87c6d49472398b61e;hb=4ece8bdd0fa36d8e69dabf8c620f9e50170000e8;hpb=87c1cd9c517bb57a537ba1f75548e6c20966553d
There were a few changes related to the HDF5 library detection in cmake recently:
https://cmake.org/gitweb?p=cmake.git;a=history;f=Modules/FindHDF5.cmake;h=50e18922ee45494eb04aa1bc991cd4070f7ec52d;hb=HEAD

I do not know what the package dependency situation is, where the HDF5 dependency comes from, and whether the C++ libraries are required. Maybe this check silently failed previously and it was not really a problem?
Comment by AK (Andreaskem) - Sunday, 31 July 2016, 09:39 GMT
Okay, I think something is wrong with the HDF5 detection in cmake.

test.c: [empty]
CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (Test)
find_package (HDF5)
add_executable(Test test.c)
target_link_libraries(Test ${HDF5_LIBRARIES})

With hdf5, cmake then looks for the C++ libraries and fails:
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- Found HDF5: /usr/lib64/libz.so;/usr/lib64/libdl.so;/usr/lib64/libm.so;HDF5_hdf5_cpp_LIBRARY-NOTFOUND;/usr/lib64/libhdf5.so (found version "1.10.0")
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
HDF5_hdf5_cpp_LIBRARY
linked by target "Test" in directory /home/andreas/Downloads/tmp

-- Configuring incomplete, errors occurred!

Installing the C++ libraries (in hdf5-openmpi or hdf5-cpp-fortran) makes the cmake command work. That should probably not happen.
Comment by patrick (potomac) - Sunday, 31 July 2016, 14:45 GMT
hdf5-openmpi and hdf5-cpp-fortran are in conflict with hdf5 :

# pacman -S hdf5-cpp-fortran

hdf5-cpp-fortran and hdf5 are in conflict. Remove hdf5? [y/N]

# pacman -S hdf5-openmpi

:: hdf5-openmpi and hdf5 are in conflict. Remove hdf5? [y/N]

is it safe to do the switch to hdf5-openmpi version ?

Comment by AK (Andreaskem) - Sunday, 31 July 2016, 19:26 GMT
Installing hdf5-cpp-fortran instead of hdf5 should be safe, it just hast the Fortran / Fortran 2003 and the C++ bindings enabled.

On the other hand, hdf5-openmpi pulls in Open MPI and has the C++ bindings enabled. This configuration is "unsupported". If you do not need the MPI support, you should probably go for hdf5-cpp-fortran, in my opinion.

I do not know if that is a workaround to your initial problem, but I strongly suspect it is.
Comment by patrick (potomac) - Tuesday, 02 August 2016, 06:01 GMT
@Andreaskem : installing hdf5-cpp-fortran solves the problem,

so a quick workaround would be to modify PKGBUILD file, by adding "hdf5-cpp-fortran" in "makedepends" section
Comment by Borche Jankovski (bokiscout) - Saturday, 06 August 2016, 06:39 GMT
I'm facing the same issue but unfortinately installing hdf5-cpp-fortran doesn't solves the problem.

Compiling with hdf5-cpp-fortran installed makes makepkg to throw this error:
fatal error: stdlib.h: No such file or directory

Here is the full output of makepkg:
-- Build files have been written to: /home/borche/opencvarch/src/opencv-3.1.0
[ 0%] Generating opencv_core_pch_dephelp.cxx
Scanning dependencies of target opencv_core_pch_dephelp
[ 0%] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o
[ 0%] Linking CXX static library ../../lib/libopencv_core_pch_dephelp.a
[ 0%] Built target opencv_core_pch_dephelp
Scanning dependencies of target pch_Generate_opencv_core
[ 1%] Generating precomp.hpp
[ 1%] Generating precomp.hpp.gch/opencv_core_Release.gch
In file included from /usr/include/c++/6.1.1/bits/stl_algo.h:59:0,
from /usr/include/c++/6.1.1/algorithm:62,
from /home/borche/opencvarch/src/opencv-3.1.0/modules/core/include/opencv2/core/base.hpp:53,
from /home/borche/opencvarch/src/opencv-3.1.0/modules/core/include/opencv2/core.hpp:54,
from /home/borche/opencvarch/src/opencv-3.1.0/modules/core/include/opencv2/core/utility.hpp:52,
from /home/borche/opencvarch/src/opencv-3.1.0/modules/core/precomp.hpp:49:
/usr/include/c++/6.1.1/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
^
compilation terminated.
make[2]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/build.make:64: modules/core/precomp.hpp.gch/opencv_core_Release.gch] Error 1
make[1]: *** [CMakeFiles/Makefile2:1796: modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
==> ERROR: A failure occurred in build().
Aborting...
[borche@manjaro opencvarch]$
Comment by Doug Newgard (Scimmia) - Saturday, 06 August 2016, 06:48 GMT
@bokiscout, that's a completely different issue, it's a borked build setup.
Comment by Bruno Pagani (ArchangeGabriel) - Tuesday, 16 January 2018, 08:37 GMT
Is this still an issue today?

Loading...