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

GDAL 3.1.3 build error on macOS 10.15.7 #3012

Closed fxcoudert closed 3 years ago

fxcoudert commented 3 years ago

Expected behavior and actual behavior.

Compilation of GDAL 3.1.3 in Homebrew is currently failing (https://github.com/Homebrew/homebrew-core/pull/61096) with:

jpeg2000_vsil_io.cpp:151:5: error: cannot initialize a member subobject of type 'int (*)(jas_stream_obj_t *, const char *, unsigned int)' (aka 'int (*)(void *, const char *, unsigned int)') with an lvalue of type 'int (jas_stream_obj_t *, char *, unsigned int)' (aka 'int (void *, char *, unsigned int)'): type mismatch at 2nd parameter ('const char *' vs 'char *')
    JPEG2000_VSIL_write,
    ^~~~~~~~~~~~~~~~~~~

This is with Jasper 2.0.21. This was reported previously in https://github.com/OSGeo/gdal/issues/2977 and @rouault stated “This has been fixed in 3.1.3”, but it is not. The type mismatch is about the const-ness of the second argument. In particular, commit https://github.com/OSGeo/gdal/commit/e236eeaed1be45a4af457565085e3db1f2fc489f did not fix that issue, which is still present in master: https://github.com/OSGeo/gdal/blob/master/gdal/frmts/jpeg2000/jpeg2000_vsil_io.cpp#L112

Steps to reproduce the problem.

Our configure line is:

./configure --prefix=/usr/local/Cellar/gdal/3.1.3 --mandir=/usr/local/Cellar/gdal/3.1.3/share/man --disable-debug --with-libtool --with-local=/usr/local/Cellar/gdal/3.1.3 --with-opencl --with-threads --with-bsb --with-grib --with-pam --with-pcidsk=internal --with-pcraster=internal --with-curl=/usr/bin/curl-config --with-expat=/usr/local/opt/expat --with-freexl=/usr/local/opt/freexl --with-geos=/usr/local/opt/geos/bin/geos-config --with-geotiff=/usr/local/opt/libgeotiff --with-gif=/usr/local/opt/giflib --with-jpeg=/usr/local/opt/jpeg --with-libjson-c=/usr/local/opt/json-c --with-libtiff=/usr/local/opt/libtiff --with-pg=yes --with-png=/usr/local/opt/libpng --with-spatialite=/usr/local/opt/libspatialite --with-sqlite3=/usr/local/opt/sqlite --with-proj=/usr/local/opt/proj --with-zstd=/usr/local/opt/zstd --with-liblzma=yes --with-cfitsio=/usr/local/opt/cfitsio --with-hdf5=/usr/local/opt/hdf5 --with-netcdf=/usr/local/opt/netcdf --with-jasper=/usr/local/opt/jasper --with-xerces=/usr/local/opt/xerces-c --with-odbc=/usr/local/opt/unixodbc --with-dods-root=/usr/local/opt/libdap --with-epsilon=/usr/local/opt/epsilon --with-webp=/usr/local/opt/webp --with-poppler=/usr/local/opt/poppler --with-armadillo=no --with-qhull=no --without-grass --without-jpeg12 --without-libgrass --without-mysql --without-perl --without-python --without-gta --without-ogdi --without-fme --without-hdf4 --without-openjpeg --without-fgdb --without-ecw --without-kakadu --without-mrsid --without-jp2mrsid --without-mrsid_lidar --without-msg --without-oci --without-ingres --without-idb --without-sde --without-podofo --without-rasdaman --without-sosi

Operating system

macOS 10.15.7 with system clang compiler and up-to-date dependencies through Homebrew.

GDAL version and provenance

3.1.3 unpatched source

rouault commented 3 years ago

I'd suggest homebrew to disable jasper and use openjpeg. openjpeg is a better alternative

fxcoudert commented 3 years ago

Thanks, we'll consider it and see what our users think. Does it have identical functionality?

rouault commented 3 years ago

Does it have identical functionality?

Yes, openjpeg is a reference implementation of JPEG2000 and those recent years it has received a number of performance implementations (single threaded and multi threaded) that make it faster

fxcoudert commented 3 years ago

Hi @rouault,

We have shipped the latest version with openjpeg (--with-openjpeg) instead of gdal, and we have a user report that this broke JPEG2000 support for them: https://github.com/Homebrew/homebrew-core/pull/61096#issuecomment-704279255

Their reproducible example is:

$ wget --no-check-certificate https://oceania.generic-mapping-tools.org/server/earth/earth_relief/earth_relief_15s_p/N00E000.earth_relief_15s_p.jp2
$ gdalinfo N00E000.earth_relief_15s_p.jp2                                     
ERROR 4: `N00E000.earth_relief_15s_p.jp2' not recognized as a supported file format.
gdalinfo failed - unable to open 'N00E000.earth_relief_15s_p.jp2'.

Could you advise on whether this is expected behaviour?

rouault commented 3 years ago

gdalinfo N00E000.earth_relief_15s_p.jp2

This works for me. Are you sure your build has the JP2OpenJPEG driver enabled ? Cf gdalinfo --format JP2OpenJPEG

fxcoudert commented 3 years ago

Am I correct in understanding that --with-openjpeg, unlike --with-jasper, does not take a path as argument?

rouault commented 3 years ago

Am I correct in understanding that --with-openjpeg, unlike --with-jasper, does not take a path as argument?

yes, it uses pkg-config to figure out the include and lib

fxcoudert commented 3 years ago

OK, found out the issue. We were passing the wrong flag. By the way, I'm getting:

configure: WARNING: unrecognized options: --with-bsb, --with-grib

Have these options been removed? Is there a replacement?

rouault commented 3 years ago

Driver disabling has been generalized . See ./configure --help | grep driver