OSGeo / gdal

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

Build fails with OSX Mojave 10.14.4 #1523

Closed bhflm closed 2 years ago

bhflm commented 5 years ago

Expected behavior and actual behavior.

Expected to work out a proper installation running pip3 install GDAL

$ pip3 install gdal
Collecting gdal
  Using cached https://files.pythonhosted.org/packages/7c/b0/a2ecb10a68a319910c4681f452c83843b99c4ef6231d33a8e55b0104a50c/GDAL-2.4.0.tar.gz
Building wheels for collected packages: gdal
  Building wheel for gdal (setup.py) ... error
  Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l5/w_9l8ff15rd_5q1n5pfk465r0000gn/T/pip-install-qw_yx00s/gdal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/l5/w_9l8ff15rd_5q1n5pfk465r0000gn/T/pip-wheel-3j2fw4gz --python-tag cp37:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.7-x86_64-3.7
  copying gdal.py -> build/lib.macosx-10.7-x86_64-3.7
  copying ogr.py -> build/lib.macosx-10.7-x86_64-3.7
  copying osr.py -> build/lib.macosx-10.7-x86_64-3.7
  copying gdalconst.py -> build/lib.macosx-10.7-x86_64-3.7
  copying gdalnumeric.py -> build/lib.macosx-10.7-x86_64-3.7
  creating build/lib.macosx-10.7-x86_64-3.7/osgeo
  copying osgeo/gnm.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
  copying osgeo/__init__.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
  copying osgeo/gdalnumeric.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
  copying osgeo/osr.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
  copying osgeo/gdal.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
  copying osgeo/ogr.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
  copying osgeo/gdal_array.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
  copying osgeo/gdalconst.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
  Fixing build/lib.macosx-10.7-x86_64-3.7/gdal.py build/lib.macosx-10.7-x86_64-3.7/ogr.py build/lib.macosx-10.7-x86_64-3.7/osr.py build/lib.macosx-10.7-x86_64-3.7/gdalconst.py build/lib.macosx-10.7-x86_64-3.7/gdalnumeric.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gnm.py build/lib.macosx-10.7-x86_64-3.7/osgeo/__init__.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdalnumeric.py build/lib.macosx-10.7-x86_64-3.7/osgeo/osr.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdal.py build/lib.macosx-10.7-x86_64-3.7/osgeo/ogr.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdal_array.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdalconst.py
  Skipping optional fixer: ws_comma
  Fixing build/lib.macosx-10.7-x86_64-3.7/gdal.py build/lib.macosx-10.7-x86_64-3.7/ogr.py build/lib.macosx-10.7-x86_64-3.7/osr.py build/lib.macosx-10.7-x86_64-3.7/gdalconst.py build/lib.macosx-10.7-x86_64-3.7/gdalnumeric.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gnm.py build/lib.macosx-10.7-x86_64-3.7/osgeo/__init__.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdalnumeric.py build/lib.macosx-10.7-x86_64-3.7/osgeo/osr.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdal.py build/lib.macosx-10.7-x86_64-3.7/osgeo/ogr.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdal_array.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdalconst.py
  Skipping optional fixer: ws_comma
  running build_ext
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -I/anaconda3/include -Wno-error=unused-command-line-argument-hard-error-in-future -Wno-error=unused-command-line-argument-hard-error-in-future -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/anaconda3/include/python3.7m -I/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/usr/local/Cellar/gdal/2.4.1_1/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -I/anaconda3/include -Wno-error=unused-command-line-argument-hard-error-in-future -Wno-error=unused-command-line-argument-hard-error-in-future -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/anaconda3/include/python3.7m -I/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/usr/local/Cellar/gdal/2.4.1_1/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o -std=c++11
  building 'osgeo._gdal' extension
  creating build/temp.macosx-10.7-x86_64-3.7
  creating build/temp.macosx-10.7-x86_64-3.7/extensions
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -I/anaconda3/include -Wno-error=unused-command-line-argument-hard-error-in-future -Wno-error=unused-command-line-argument-hard-error-in-future -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/anaconda3/include/python3.7m -I/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/usr/local/Cellar/gdal/2.4.1_1/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.7-x86_64-3.7/extensions/gdal_wrap.o -std=c++11 -I/usr/local/Cellar/gdal/2.4.1_1/include
  warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
  warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
  warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
  extensions/gdal_wrap.cpp:3096:10: fatal error: 'stdexcept' file not found
  #include <stdexcept>
           ^~~~~~~~~~~
  3 warnings and 1 error generated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for gdal
  Running setup.py clean for gdal
Failed to build gdal
Installing collected packages: gdal
  Running setup.py install for gdal ... error
    Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l5/w_9l8ff15rd_5q1n5pfk465r0000gn/T/pip-install-qw_yx00s/gdal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/l5/w_9l8ff15rd_5q1n5pfk465r0000gn/T/pip-record-n17vun3i/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.7-x86_64-3.7
    copying gdal.py -> build/lib.macosx-10.7-x86_64-3.7
    copying ogr.py -> build/lib.macosx-10.7-x86_64-3.7
    copying osr.py -> build/lib.macosx-10.7-x86_64-3.7
    copying gdalconst.py -> build/lib.macosx-10.7-x86_64-3.7
    copying gdalnumeric.py -> build/lib.macosx-10.7-x86_64-3.7
    creating build/lib.macosx-10.7-x86_64-3.7/osgeo
    copying osgeo/gnm.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
    copying osgeo/__init__.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
    copying osgeo/gdalnumeric.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
    copying osgeo/osr.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
    copying osgeo/gdal.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
    copying osgeo/ogr.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
    copying osgeo/gdal_array.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
    copying osgeo/gdalconst.py -> build/lib.macosx-10.7-x86_64-3.7/osgeo
    Fixing build/lib.macosx-10.7-x86_64-3.7/gdal.py build/lib.macosx-10.7-x86_64-3.7/ogr.py build/lib.macosx-10.7-x86_64-3.7/osr.py build/lib.macosx-10.7-x86_64-3.7/gdalconst.py build/lib.macosx-10.7-x86_64-3.7/gdalnumeric.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gnm.py build/lib.macosx-10.7-x86_64-3.7/osgeo/__init__.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdalnumeric.py build/lib.macosx-10.7-x86_64-3.7/osgeo/osr.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdal.py build/lib.macosx-10.7-x86_64-3.7/osgeo/ogr.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdal_array.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdalconst.py
    Skipping optional fixer: ws_comma
    Fixing build/lib.macosx-10.7-x86_64-3.7/gdal.py build/lib.macosx-10.7-x86_64-3.7/ogr.py build/lib.macosx-10.7-x86_64-3.7/osr.py build/lib.macosx-10.7-x86_64-3.7/gdalconst.py build/lib.macosx-10.7-x86_64-3.7/gdalnumeric.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gnm.py build/lib.macosx-10.7-x86_64-3.7/osgeo/__init__.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdalnumeric.py build/lib.macosx-10.7-x86_64-3.7/osgeo/osr.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdal.py build/lib.macosx-10.7-x86_64-3.7/osgeo/ogr.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdal_array.py build/lib.macosx-10.7-x86_64-3.7/osgeo/gdalconst.py
    Skipping optional fixer: ws_comma
    running build_ext
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -I/anaconda3/include -Wno-error=unused-command-line-argument-hard-error-in-future -Wno-error=unused-command-line-argument-hard-error-in-future -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/anaconda3/include/python3.7m -I/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/usr/local/Cellar/gdal/2.4.1_1/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -I/anaconda3/include -Wno-error=unused-command-line-argument-hard-error-in-future -Wno-error=unused-command-line-argument-hard-error-in-future -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/anaconda3/include/python3.7m -I/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/usr/local/Cellar/gdal/2.4.1_1/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o -std=c++11
    building 'osgeo._gdal' extension
    creating build/temp.macosx-10.7-x86_64-3.7
    creating build/temp.macosx-10.7-x86_64-3.7/extensions
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -I/anaconda3/include -Wno-error=unused-command-line-argument-hard-error-in-future -Wno-error=unused-command-line-argument-hard-error-in-future -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/anaconda3/include/python3.7m -I/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/usr/local/Cellar/gdal/2.4.1_1/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.7-x86_64-3.7/extensions/gdal_wrap.o -std=c++11 -I/usr/local/Cellar/gdal/2.4.1_1/include
    warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
    warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
    warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
    extensions/gdal_wrap.cpp:3096:10: fatal error: 'stdexcept' file not found
    #include <stdexcept>
             ^~~~~~~~~~~
    3 warnings and 1 error generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l5/w_9l8ff15rd_5q1n5pfk465r0000gn/T/pip-install-qw_yx00s/gdal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/l5/w_9l8ff15rd_5q1n5pfk465r0000gn/T/pip-record-n17vun3i/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/l5/w_9l8ff15rd_5q1n5pfk465r0000gn/T/pip-install-qw_yx00s/gdal/

(no problems with brew install gdal)

actual behaviour:

Steps to reproduce the problem.

just run the following command with osx 10.14.4 pip3 install GDAL

and output will be similar

$ gdalinfo --version
GDAL 2.4.1, released 2019/03/15

Operating system

macOS Mojave 10.14.4

GDAL version and provenance

2.4.1

Related : https://github.com/OSGeo/gdal/issues/1465

bhflm commented 5 years ago

Found a workaround in the meantime : https://gis.stackexchange.com/questions/306473/getting-ogr-to-work-on-a-mac

mloskot commented 5 years ago

I'm not OSX user myself, but it seems to me that the following workaround from https://github.com/neovim/neovim/issues/9050#issuecomment-424417456 may be required

Starting with Mojave, the headers are no longer installed under /usr/include/ by default
-- look under Command Line Tools -> New Features in the release notes.

Running

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

from the command line fixes the issue (at least for me and using brew).
bhflm commented 5 years ago

Already tried, didn't work !

XingweiXW commented 5 years ago

Hi, I get the exact same error as yours, have you solved the problem?

forestgnome commented 5 years ago

Hi, This a c++-conflict introduced with #include and the builtin macos deployment target of 10.6 with the Python tool chain, which is not controlled by "configure", but by the python toolchain.

I see no other simple solution, than to raise the required macos deployment target to 10.9. Using the following python-sentence in GDAL/swig/python/setup.py fixes:

Required changes are inserted at lines 330-334:

...

extra_link_args = []
extra_compile_args = []

if sys.platform == 'darwin' and [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]:
    os.environ['ARCHFLAGS'] = '-mmacosx-version-min=10.9'

gdal_module = Extension('osgeo._gdal',
                        sources=['extensions/gdal_wrap.cpp'],
                        extra_compile_args=extra_compile_args,
                        extra_link_args=extra_link_args)

...

11,0,0 is the Kernel Version 11.0.0 and corresponds to Mac OS X v10.7.0 (see wikipedia). Since then, the feature "macosx-version-min" is available.

I think to price is not too high, that the runtime requirements are raised to 10.9 for the python interface. All remaining compiled GDAL-stuff is controlled by configure and remains untouched. Works with XCode 10.2.1, macos 10.4.5, GDAL 2.4.2/GDAL3.0.1 releases from github

rouault commented 5 years ago

@forestgnome Can you issue a pull request with that change ?

forestgnome commented 5 years ago

yes, I can do it, not today...

rouault commented 4 years ago

@forestgnome still willing to contribute PR ?

forestgnome commented 4 years ago

Yes, I am willing if it helps, although some problems have disappeared somewhere in 2019: currently GDAL 3.0.4 happily compiles on macos 10.5.4 with XCode 11 fine (without any modification of the released source tree) I am not sure, which layer (GDAL-configure,python,macos-SDK) actually solved the problem...

here are my configure-details: PROJ 6.3 Postgres 12 configure \ CFLAGS="-mmacosx-version-min=$OSX_MinVersion -stdlib=libc++ -I$pcreDir/include" \ CPPFLAGS="-mmacosx-version-min=$OSX_MinVersion -stdlib=libc++ -I$pcreDir/include" \ LDFLAGS="-mmacosx-version-min=$OSX_MinVersion -L$pcreDir/lib -L$fwOSGeoRasterDir/netcdf/$NetCDF_VersionLinked/lib -lnetcdf" \ PQ_CFLAGS="-I$pgDir/include" \ PQ_LIBS="-L$pgDir/lib -lpq" \ --prefix=$fwDir \ --disable-static \ --without-grass \ --with-curl \ --with-cpp14 \ --with-expat=/usr/local \ --with-geos=$fwOSGeoSpatialDir/geos/$GEOS_VersionLinked/bin/geos-config \ --with-geotiff=internal \ --with-gif \ --with-hdf5=$fwOSGeoRasterDir/hdf/$HDF_VersionLinked \ --with-jasper \ --with-jpeg=$fwOSGeoRasterDir/jpeg/$JPEG_VersionLinked \ --with-libkml=$fwOSGeoSpatialDir/libkml/$LIBKML_VersionLinked \ --with-netcdf=$fwOSGeoRasterDir/netcdf/$NetCDF_VersionLinked \ --with-opencl \ --with-openjpeg=$openjpegDir \ --with-pcraster=internal \ --with-pcre \ --with-pg \ --with-png=$fwOSGeoRasterDir/png/$PNG_VersionLinked \ --with-proj=$fwOSGeoSpatialDir/proj/$PROJ_VersionLinked \ --with-python=/Library/Frameworks/Python.framework/Versions/$Python_Version/bin/python$Python_Version \ --with-qhull=internal \ --with-threads \ --with-sfcgal \ --with-sqlite3=$sqliteDir \ --with-spatialite=$fwOSGeoSpatialDir/spatiaLite/$SpatiaLite_VersionLinked

jratike80 commented 3 years ago

Pending for closing. It seems that the problem does not exist at the moment (2021-02-11).

lamy199 commented 3 years ago

Urgent, Urgent, Urgent..... Hello every body, when I import gdal from osgeo on mac Mojave I have this ERROR. please can you help me "ERROR 1: dlopen(/Library/Application Support/GDAL/3.2/PlugIns/gdal_MrSID.dylib, 1): Library not loaded: @loader_path/../Libraries/libltidsdk.9.dylib Referenced from: /Library/Application Support/GDAL/3.2/PlugIns/gdal_MrSID.dylib Reason: image not found ERROR 1: dlopen(/Library/Application Support/GDAL/3.2/PlugIns/gdal_MrSID.dylib, 1): Library not loaded: @loader_path/../Libraries/libltidsdk.9.dylib Referenced from: /Library/Application Support/GDAL/3.2/PlugIns/gdal_MrSID.dylib Reason: image not found ERROR 1: dlopen(/Library/Application Support/GDAL/3.2/PlugIns/gdal_ECW_JP2ECW.dylib, 1): Library not loaded: /Library/Application Support/GDAL/3.2/Libraries/libNCSEcw.dylib Referenced from: /Library/Application Support/GDAL/3.2/PlugIns/gdal_ECW_JP2ECW.dylib Reason: image not found ERROR 1: dlopen(/Library/Application Support/GDAL/3.2/PlugIns/gdal_ECW_JP2ECW.dylib, 1): Library not loaded: /Library/Application Support/GDAL/3.2/Libraries/libNCSEcw.dylib Referenced from: /Library/Application Support/GDAL/3.2/PlugIns/gdal_ECW_JP2ECW.dylib Reason: image not found ERROR 1: dlopen(/Library/Application Support/GDAL/3.2/PlugIns/gdal_MG4Lidar.dylib, 1): Library not loaded: @loader_path/../Libraries/liblti_lidar_dsdk.1.dylib Referenced from: /Library/Application Support/GDAL/3.2/PlugIns/gdal_MG4Lidar.dylib Reason: image not found ERROR 1: dlopen(/Library/Application Support/GDAL/3.2/PlugIns/gdal_MG4Lidar.dylib, 1): Library not loaded: @loader_path/../Libraries/liblti_lidar_dsdk.1.dylib Referenced from: /Library/Application Support/GDAL/3.2/PlugIns/gdal_MG4Lidar.dylib Reason: image not found"

jratike80 commented 3 years ago

All errors refer to plugins which require additional and non open source components. Remove the plugins and and errors should go away. If you need one or more of those plugins you can write mail to gdal-dev mailing list and ask for help. I suggest not to label that mail as urgent.

rouault commented 2 years ago

closing as configure has been removed in GDAL master and replaced by cmake. reopen a new one if there's still an issue