Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sf installation problem under Mac OS 11 - Big Sur #1542

Closed
duccioa opened this issue Nov 17, 2020 · 15 comments
Closed

sf installation problem under Mac OS 11 - Big Sur #1542

duccioa opened this issue Nov 17, 2020 · 15 comments

Comments

@duccioa
Copy link

duccioa commented Nov 17, 2020

Hello,
After the update to Big Sur, the installation of sf broke.
The installation with brew as suggested by @abuabara in #1536 gives the following warning:

==> Pouring gdal-3.2.0.big_sur.bottle.tar.gz
Warning: gdal dependency gcc was built with a different C++ standard
library (libstdc++ from clang). This may cause problems at runtime.

rgeos

If I install rgeos from source:

install.packages("rgeos", repos="http://R-Forge.R-project.org",  type="source")

#> configure: error: geos_c.h not found in standard or given locations.

If I install it from binary it works:

install.packages("rgeos")
library(rgeos)

#> Loading required package: sp
#> rgeos version: 0.5-5, (SVN revision 640)
#>  GEOS runtime version: 3.8.1-CAPI-1.13.3 
#>  Linking to sp version: 1.4-2 
#>  Polygon checking: TRUE 

rgdal

If I install rgdal from source I get this error:

install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")

# Below an extract of a long list of errors
#> ...
#> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:327:9: 
#> error: no member named 'islessgreater' in the global namespace
#> using ::islessgreater;
#>      ~~^
#>                                                ^
#> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:646:17: 
#> error: no template named 'numeric_limits'
#>   static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
#>                 ^
#> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:649:25: 
#> error: no template named 'numeric_limits'
#>   return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
#>                        ^
#> fatal error: too many errors emitted, stopping now [-ferror-limit=]
#> 193 warnings and 20 errors generated.
#> configure: Install failure: compilation and/or linkage problems.

#> configure: error: GDALAllRegister not found in libgdal.

If I install it from binary, I get this error:

install.packages("rgdal")
library(rgdal)

#> Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
#> unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so':
#> dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so, 6): Library not loaded: /usr/lib/libpq.5.dylib
 #> Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so
 #> Reason: image not found

sf

If I install directly sf, I get the same error as in gdal

Thank you

@gilbertocamara
Copy link

I managed to get "sf" to run on MacOS 11.0.1 (BigSur) by recompiling most of the required packages. Here's the recipe:

  1. Remove all spatial software from brew (if you installed it). Rgdal does not like "brewed" stuff (I believe Roger prefers wine). seriously, rgdal looks for libraries in their default places and not in the "Cellar" libraries used by "brew".

  2. Install Xcode 12.3beta (downloaded from Apple Developers). This is the latest version of XCode which is compatible with MacOS BigSur.

  3. Install "wget" using brew:

"brew install wget".

  1. Download the libraries below from their sources:

(a) sqlite-autoconf-3330000.tar.gz from "https://www.sqlite.org/download.html".
(b) tiff-4.1.0.tar.gz from "https://download.osgeo.org/libtiff/"
(c) proj-7.2.0.tar.gz from "https://proj.org/download.html#current-release"
(d) libgeotiff-1.6.0.tar.gz from "https://download.osgeo.org/geotiff/libgeotiff/"
(e) geos-3.8.1.tar.bz2 from "https://trac.osgeo.org/geos"
(f) gdal-3.2.0.tar.gz from "https://gdal.org/download.html"

  1. In the order given above, unpack each library and then execute the following commands:

% sudo ./configure
% sudo make
% sudo make install

  1. Now you are ready to compile "rgdal" and "sf" from source. Using the R console,do:

install.packages("rgdal", type = "source")
install.packages("sf", type = "source")

  1. After those steps, both "rgdal" and "sf" are working on MacOS BigSur.

@gilbertocamara
Copy link

Important update from Simon Urbanek:
CRAN libraries have been updated to be compatible with Big Sur which removed some system libraries, so just re-install rgdal and sf from CRAN. To make sure you get the latest versions use
install.packages(c("rgdal","sf"),,"https://mac.R-project.org"). So there's no need to compile everything.

@duccioa
Copy link
Author

duccioa commented Nov 20, 2020

Thank you for the detailed explanation, I'll try and get back with the results.
One thing, I have installed Xcode beta but the previous version is still there and now I have two versions on my system. Shall I remove the old one?

@gilbertocamara
Copy link

gilbertocamara commented Nov 20, 2020 via email

@duccioa
Copy link
Author

duccioa commented Nov 20, 2020

Great, I managed to install everything I need. Thank you!
Duccio

@duccioa duccioa closed this as completed Nov 26, 2020
@duccioa
Copy link
Author

duccioa commented Nov 26, 2020

The problem has been solved and rgdal and so sf can be installed regularly from CRAN

@anirbanmajumdar
Copy link

** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path

  • DONE (rgdal)
  • installing source package ‘sf’ ...
    ** package ‘sf’ successfully unpacked and MD5 sums checked
    ** using staged installation
    configure: CC: /usr/local/Cellar/gcc/9.1.0/bin/gcc-7
    configure: CXX: /usr/local/bin/ccache /usr/local/opt/llvm/bin/clang++ -std=c++11
    checking for gdal-config... /usr/local/bin/gdal-config
    checking gdal-config usability... yes
    configure: GDAL: 3.2.0
    checking GDAL version >= 2.0.1... yes
    checking for gcc... /usr/local/Cellar/gcc/9.1.0/bin/gcc-7
    checking whether the C compiler works... no
    configure: error: in /private/var/folders/y2/2_2brn6x4871ymtyc7dx8wyr0000gn/T/RtmpoMThLf/R.INSTALL7d5011572784/sf': configure: error: C compiler cannot create executables See config.log' for more details
    ERROR: configuration failed for package ‘sf’
  • removing ‘/Users/xxxx/Rlibs/sf’
  • restoring previous ‘/Users/xxxx/Rlibs/sf’

The downloaded source packages are in
‘/private/var/folders/y2/2_2brn6x4871ymtyc7dx8wyr0000gn/T/RtmpHJuiwy/downloaded_packages’
Warning message:
In install.packages(c("rgdal", "sf"), , "https://mac.R-project.org") :
installation of package ‘sf’ had non-zero exit status

I am not able to compile sf. Any ideas?

@gilbertocamara
Copy link

gilbertocamara commented Jan 12, 2021 via email

@elbamos
Copy link

elbamos commented Feb 23, 2021

Has anyone gotten this to work on an M1 (Apple Silicon) machine with R-devel?

Using:

	options(
		configure.args=c(
			rgdal=c("--with-gdal-config=/opt/homebrew/bin/gdal-config"),
			sf=c("--with-gdal-config=/opt/homebrew/bin/gdal-config --with-geos-config=/opt/homebrew/bin/geos-config")
		)
	)

I get:

checking GDAL: checking whether PROJ is available fur running:... ./configure: line 3614: 97479 Killed: 9               ./gdal_proj
no
configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?
ERROR: configuration failed for package ‘sf’

For the sf package, and

checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/private/tmp/RtmpTjfuN5/R.INSTALL17d3b1d9972cf/rgdal':
configure: error: cannot run C++ compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
ERROR: configuration failed for package ‘rgdal’

for rgdal.

Interestingly, I had these compiling properly with an earlier version of R-devel and the homebrew libraries, I'm not sure what change broke the installation.

@edzer
Copy link
Member

edzer commented Feb 24, 2021

configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?

This indicates that you are trying to link against a GDAL version that was not compiled against PROJ; sf requires this.

@elbamos
Copy link

elbamos commented Feb 24, 2021

My gdal is definitely linked against proj. From otool -L libgdal.dylib:

/opt/homebrew/opt/proj/lib/libproj.19.dylib (compatibility version 22.0.0, current version 22.1.0)

And when installing sf I do see this before the error:

checking GDAL: checking whether PROJ is available for linking:... yes

@edzer
Copy link
Member

edzer commented Feb 24, 2021

And this?

configure: error: cannot run C++ compiled programs.

@gilbertocamara
Copy link

gilbertocamara commented Feb 24, 2021 via email

@elbamos
Copy link

elbamos commented Feb 24, 2021

I just confirmed that the command line tools are installed and up to date. (Everything else is also able to compile and install properly.)

@elbamos
Copy link

elbamos commented Feb 25, 2021

Update: I was able to get sf to compile and execute properly after building libgdal and libproj from source. So I think there's something off in the current arm64 libraries available from homebrew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants