Skip to content

rgdal with R > 3.5.x and GDAL > 2.3.x on macOS

4 messages · Patrick Schratz, Roger Bivand

#
Hi,

desperately trying to get rgdal installed on R > 3.5.x with GDAL 2.3.0 on macOS High Sierra.
I am aware of the discussion that a suitable compiler is needed since GDAL > 2.3.0.

I've set
CC=clang
CXX=clang++
PKG_CXXFLAGS= -stdlib=libc++ -std=c++11

In ~/.R/Makevars as suggested here https://github.com/r-spatial/sf/issues/726
The automated checking during the rgdal installation shows that C++11 support is available.
But still it complains about a lacking C++11 support.
I've searched the web but could not find anything helpful. If I've overlooked something, please just point me to the link.

Everything installed via homebrew (bottles)
R 3.5.1
proj 5.1.0 (osgeo4mac)
gdal 2.3.1 (homebrew core)

macOS 10.13.1 (High Sierra)
Installing package into ?/usr/local/lib/R/3.5/site-library?
(as ?lib? is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.3-4.tar.gz'
Content type 'application/x-gzip' length 1664774 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

* installing *source* package ?rgdal? ...
** package ?rgdal? successfully unpacked and MD5 sums checked
configure: R_HOME: /usr/local/Cellar/r/3.5.1/lib/R
configure: CC: clang
configure: CXX: clang++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... yes
configure: svn revision: 766
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.1
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
In file included from gdal_test.cc:1:
In file included from /usr/local/Cellar/gdal2/2.3.1/include/gdal.h:45:
/usr/local/Cellar/gdal2/2.3.1/include/cpl_port.h:187:6: error: Must have C++11 or newer.
# error Must have C++11 or newer.
^
1 error generated.
In file included from gdal_test.cc:1:
In file included from /usr/local/Cellar/gdal2/2.3.1/include/gdal.h:45:
/usr/local/Cellar/gdal2/2.3.1/include/cpl_port.h:187:6: error: Must have C++11 or newer.
# error Must have C++11 or newer.
^
1 error generated.
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ?rgdal?
* removing ?/usr/local/lib/R/3.5/site-library/rgdal?
Warning in install.packages :
installation of package ?rgdal? had non-zero exit status

The downloaded source packages are in
?/private/var/folders/nv/k87rzvfs55l6j6xt_0jwb4wm0000gn/T/Rtmp68hYW1/downloaded_packages?
Installing package into ?/usr/local/lib/R/3.5/site-library?
(as ?lib? is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.3-4.tar.gz'
Content type 'application/x-gzip' length 1664774 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

* installing *source* package ?rgdal? ...
** package ?rgdal? successfully unpacked and MD5 sums checked
configure: R_HOME: /usr/local/Cellar/r/3.5.1/lib/R
configure: CC: clang
configure: CXX: clang++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... yes
configure: svn revision: 766
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.1
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
In file included from gdal_test.cc:1:
In file included from /usr/local/Cellar/gdal/2.3.1_1/include/gdal.h:45:
/usr/local/Cellar/gdal/2.3.1_1/include/cpl_port.h:187:6: error: Must have C++11 or newer.
# error Must have C++11 or newer.
^
1 error generated.
In file included from gdal_test.cc:1:
In file included from /usr/local/Cellar/gdal/2.3.1_1/include/gdal.h:45:
/usr/local/Cellar/gdal/2.3.1_1/include/cpl_port.h:187:6: error: Must have C++11 or newer.
# error Must have C++11 or newer.
^
1 error generated.
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ?rgdal?
* removing ?/usr/local/lib/R/3.5/site-library/rgdal?
Warning in install.packages :
installation of package ?rgdal? had non-zero exit status

The downloaded source packages are in
?/private/var/folders/nv/k87rzvfs55l6j6xt_0jwb4wm0000gn/T/Rtmp68hYW1/downloaded_packages?
#
See below inline:
On Mon, 6 Aug 2018, Patrick Schratz wrote:

            
Does anyone actually know that this is a solution or rather the problem? 
Check:

$ R CMD config CXX
## clang++ -std=gnu++11
## for me with an R-devel clang build on Fedora 28

Run this and/or ./configure in the unpacked rgdal source tarball and 
report the CXX value. Is the issue advice wrong, and CXX should be 
'clang++ -std=gnu++11'?

I have no access to OSX (and no wish to have access) - the OSX users need 
to do a full bisection and not guess what is happening.
No, that is coming from code in GDAL itself, as you can see. You need to 
establish which --std= is actually needed.
Searching the web only confirms that there is very little signal there - 
search the source code instead, and bisection (which settings worked for 
which versions, and which changes provoke the issue)? Is for example the 
CRAN R binary reporting a different R CMD config CXX from your 
homebrew-built R?
#
Hi Roger,

thanks for taking the time. To defend myself, I do not use macOS on a daily base and just run it in a VM for some package testing.
This seems to be the problem. Using your configuration works!
I am aware of the small geospatial com on mac and that the osgeo4mac repo is not very stable. However I think there is a need for a short guide how to either use the kyngchaos frameworks or the osgeo4mac repo to have a stable geospatial toolset for R (starting with rgdal to sf and so on). Ideally for different R versions if major changes occured. A good place would be the README of rgdal if would be hosted on r-spatial on Github as most people would look there. As I saw in some issues, people sometimes think the cran/rgdal mirror is the place to go. But thats all just suggestions ;)
This little issue costed me at least 3h. Its really annyoing to have such issues on macOS from time to time (but ofc this is not your or anyone else fault).
Thanks again!!
Patrick
On Aug 6 2018, at 11:05 am, Roger Bivand <Roger.Bivand at nhh.no> wrote:

  
  
#
On Mon, 6 Aug 2018, Patrick Schratz wrote:

            
More luck you than me - I haven't repeated trying to test on OSX for 
years - regular users need to find ways of sharing information but volume 
on R-sig-mac is low.
So R CMD config CXX on your system returned 'clang++ -std=gnu++11'? Please 
let me know off-list, and I'll update the sf issue.
Volunteers welcome - it would be easiest to maintain if those doing it had 
a CI framework. I think it is also a mindset thing, OSX should be easier 
than Windows, but often isn't, partly because of Apple making changes that 
are not backward-compatible.
Life isn't supposed to be easy, unless one believes the sales talk ... 
thanks for contributing the issue anyway, maybe the signal will get a bit 
stronger ...

Roger