OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.79k stars 2.51k forks source link

configure: error: HDF5 support requested with arg..., but no hdf5 lib found #2053

Closed einzigsue closed 2 years ago

einzigsue commented 4 years ago

Hi All

The configure process doesn't pick up the existing hdf5 library I passed through the following command line """ $ ./configure --prefix=$APP_PATH --with-gnu-ld --with-python=$PYTHON3_ROOT/bin/python3 --with-java=$JAVA_ROOT--with-hdf4=$HDF4_ROOT --with-hdf5=$HDF5_ROOT --with-netcdf=$NETCDF_ROOT --with-geos=yes --with-cfitsio=$CFITSIO_ROOT/lib --with-xerces=$XERCES_ROOT --with-xerces-inc=$XERCES_ROOT/include --with-xerces-lib="-L/apps/xerces-c/3.2.2/lib -lxerces-c-3.2" --with-proj=$PROJ_ROOT --with-gif=/usr/lib64 --with-png=/usr/lib64 --with-jasper=/user/lib64 --with-libtiff=/usr/lib64 --with-jpeg=/usr/lib64 --with-geotiff=internal """ The error message says """ ..... checking for H5Fopen in -lhdf5... no configure: error: HDF5 support requested with arg /apps/hdf5/1.10.5, but no hdf5 lib found """ But I got """ $ ls -ltrah $HDF5_ROOT/lib/libhdf5.so lrwxrwxrwx 1 apps z30 18 Nov 4 17:25 /apps/hdf5/1.10.5/lib/libhdf5.so -> libhdf5.so.103.1.0 """ and """ $ nm $HDF5_ROOT/lib/libhdf5.so | grep H5Fopen 00000000000f8555 T H5Fopen """ I also added the line """ echo $LIBS """ into the file ./configure after this section """ if test -d $with_hdf5/lib ; then HDF5_LIB_DIR=$with_hdf5/lib else HDF5_LIB_DIR=$with_hdf5 fi

ORIG_LIBS="$LIBS" LIBS="-L$HDF5_LIB_DIR $LIBS -lhdf5" """ and before it checks for the function H5Fopen. The variable LIBS is printed as """ -L/apps/hdf5/1.10.5/lib -L/usr/lib64 -L/usr/lib64/lib -lgif -L/usr/lib64 -L/usr/lib64/lib -ljpeg -L/usr/lib64/lib -ltiff -L/usr/lib64 -L/usr/lib64/lib -lpng -L/apps/cfitsio/3.47/lib -L/apps/cfitsio/3.47/lib/lib -lcfitsio -lpq -L/apps/proj/6.2.1/lib -lproj -lz -lpthread -lm -lrt -ldl -lhdf5 """ Why it doesn't pickup the hdf5 library pre-installed in my system? I actually browsed through the configure file and don't understand why ${ac_cv_lib_hdf5_H5Fopen+:} false is true and where actually the variable is set.

I have to say the following if-elif-else-fi statement is not very reader friendly. """ if test "$with_hdf5" = "no" ; then

HAVE_HDF5=no

echo "hdf5 support disabled."

elif test "$with_hdf5" = "yes" -o "$with_hdf5" = "" ; then

HDF5_CFLAGS="" HDF5_LIBS="" ... else

if test -d $with_hdf5/lib ; then HDF5_LIB_DIR=$with_hdf5/lib else HDF5_LIB_DIR=$with_hdf5 fi

ORIG_LIBS="$LIBS" LIBS="-L$HDF5_LIB_DIR $LIBS -lhdf5" echo $LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: checking for H5Fopen in -lhdf5" >&5 $as_echo_n "checking for H5Fopen in -lhdf5... " >&6; } if ${ac_cv_lib_hdf5_H5Fopen+:} false; then : $as_echo_n "(cached) " >&6 else .... fi ... fi """ It tooks me hours to figure out the structure but I got even more confused about where the variable ac_cv_lib_hdf5_H5Fopen is defined.

Steps to reproduce the problem.

wget https://github.com/OSGeo/gdal/releases/download/v3.0.2/gdal-3.0.2.tar.gz tar -xzf gdal-3.0.2.tar.gz cd gdal-3.0.2 %%% I set the system specific variables like APP_PATH, PYTHON3_ROOT, and HDF5_ROOT here. ./configure --prefix=$APP_PATH --with-gnu-ld --with-python=$PYTHON3_ROOT/bin/python3 --with-java=$JAVA_ROOT--with-hdf4=$HDF4_ROOT --with-hdf5=$HDF5_ROOT --with-netcdf=$NETCDF_ROOT --with-geos=yes --with-cfitsio=$CFITSIO_ROOT/lib --with-xerces=$XERCES_ROOT --with-xerces-inc=$XERCES_ROOT/include --with-xerces-lib="-L/apps/xerces-c/3.2.2/lib -lxerces-c-3.2" --with-proj=$PROJ_ROOT --with-gif=/usr/lib64 --with-png=/usr/lib64 --with-jasper=/user/lib64 --with-libtiff=/usr/lib64 --with-jpeg=/usr/lib64 --with-geotiff=internal

Operating system

$ lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 8.0.1905 (Core) Release: 8.0.1905 Codename: Core

GDAL version and provenance

3.0.2

Dave-Allured commented 4 years ago

Here are a couple of random hacking suggestions. I just built gdal 3.0.1 on Mac yesterday with HDF5, and no problem. Try configure with --with-hdf5=$HDF5_ROOT and nothing else. If that works, then try adding --prefix and --with-gnu-ld, one at a time.

I hesitate to suggest backing down from 3.0.2 to 3.0.1, because 3.0.2 is billed as a relatively simple bug fix release. That should not matter.

This message: checking for H5Fopen in -lhdf5... no is probably based on the result of a trivial test program that is run internally by the configure script. Check config.log and see if it actually displays the test program source code and the command used to run it. If so, then try running this as a stand-alone program outside of configure. I have very rarely used this to gain insights into linking problems. This gets you away from the delightful intricacies of the configure script.

Dave-Allured commented 4 years ago

It looks to me like either --with-xerces-inc should include "-I", or else --with-xerces-lib should NOT include "-L". What is going on with that?

Dave-Allured commented 4 years ago

Never mind about that last remark. configure --help indicates your usage of --with-xerces_* is supported.

MaxRev-Dev commented 4 years ago

Encountered the same issue on CenOS7.

This is not the only library with the same problem. I can't normally configure also:

GDAL can not find hdf5 libraries from vcpkg in headers (for me they are build to ${vc_packages}/include path). It's likely a collision between configured libraries?

I have installed static hdf5 and expat libraries. export PKG_CONFIG_PATH="${vc_packages}/lib/pkgconfig"

I've tried HDF5_CFLAGS andHDF5_LIBS but they are ignored by configure. Resolved with yum install hdf5-devel and configuring against /usr/lib64.

--with-hdf4 \
--with-hdf5="/usr/lib64" \
--with-expat=${vc_packages}

Truncated configure output:

checking for Expat XML Parser... yes
checking if Expat XML Parser version is >= 1.95.0... yes
....
checking for H5Fopen in -lhdf5... yes
lbartoletti commented 3 years ago

Same issue (gdal 3.2.3, hdf5-1.10 on centos7)

I noticed the failed tests was: $LOCROOT/usr/local/bin/gcc -o conftest -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -g -O2 -fPIC -fvisibility=hidden conftest.c -lhdf5 -lhdf5 -L$LOCROOT/usr/local/lib -L$LOCROOT/usr/local -L$LOCROOT/usr/local/lib -lpng -L$LOCROOT/usr/local/lib -lpq -L$LOCROOT/usr/local/lib -lsqlite3 -lproj -L$LOCROOT/usr/local/lib -lsqlite3 -lz -L$LOCROOT/usr/local -L$LOCROOT/usr/local/lib -lpthread -lm -lrt -ldl -L$LOCROOT/usr/local/lib -lspatialite -lhdf5

My problem was, my problem was that I didn't have libpng installed in this folder... I don't know if this will help you, but for me it works.

rouault commented 2 years ago

closing as configure has been removed and replaced by cmake

Shawn1874 commented 9 months ago

I know it is closed but I had the same issue recently which could also occur when linking dynamic libraries and using cmake. In my case the real problem wasn't that hdf5 wasn't found but that the hdf5 library was dynamically linked to something else such as libsz which wasn't found. I had to set LD_LIBRARY_PATH since the libsz was linked dynamically. Using LDFLAGS to specify the path to libraries did not fix all of the issues related to finding other libraries.

Dave-Allured commented 9 months ago

If you are still having a problem, please start a new issue, or post to the user list. Include your specific error message and version information.

rouault commented 9 months ago

I had to set LD_LIBRARY_PATH since the libsz was linked dynamically.

that's fully expected if libsz isn't in a directory that is searched by default for dynamic library loaded. No bug here. Just standard operating system working