Problem installing package sf

Hello everyone! I'm new to posit cloud and I'm trying to install the sf package and I get the following error:

> install.packages("sf")
Installing package into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'http://rspm/default/__linux__/focal/latest/src/contrib/sf_1.0-10.tar.gz'
Content type 'application/x-gzip' length 3541121 bytes (3.4 MB)
==================================================
downloaded 3.4 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc
configure: CXX: g++ -std=gnu++14
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.0.4
checking GDAL version >= 2.0.1... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 3.0.4
configure: pkg-config proj exists, will use it
configure: using proj.h.
configure: PROJ: 6.3.1
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... yes
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.8.0
checking GEOS version >= 3.4.0... yes
checking for geos_c.h... yes
checking geos: linking with -L/usr/lib/x86_64-linux-gnu -lgeos_c... yes
configure: Package CPP flags:   -DHAVE_PROJ_H -I/usr/include/gdal -I/usr/include
configure: Package LIBS: -lproj   -L/usr/lib -lgdal -L/usr/lib/x86_64-linux-gnu -lgeos_c
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++14 -I"/opt/R/4.2.3/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/usr/include/gdal -I/usr/include -I'/cloud/lib/x86_64-pc-linux-gnu-library/4.2/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++14 -I"/opt/R/4.2.3/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/usr/include/gdal -I/usr/include -I'/cloud/lib/x86_64-pc-linux-gnu-library/4.2/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c bbox.cpp -o bbox.o
g++ -std=gnu++14 -I"/opt/R/4.2.3/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/usr/include/gdal -I/usr/include -I'/cloud/lib/x86_64-pc-linux-gnu-library/4.2/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c gdal.cpp -o gdal.o
gdal.cpp: In function ‘Rcpp::List CPL_crs_parameters(Rcpp::List)’:
gdal.cpp:328:40: error: no matching function for call to ‘OGRSpatialReference::GetAxis(const char [7], int&, OGRAxisOrientation*, double*)’
  328 |       i, &peOrientation, &pdfConvFactor);
      |                                        ^
In file included from /usr/include/gdal/ogr_geometry.h:38,
                 from /usr/include/gdal/ogr_feature.h:36,
                 from /usr/include/gdal/gdal_priv.h:77,
                 from gdal.cpp:4:
/usr/include/gdal/ogr_spatialref.h:250:17: note: candidate: ‘const char* OGRSpatialReference::GetAxis(const char*, int, OGRAxisOrientation*) const’
  250 |     const char *GetAxis( const char *pszTargetKey, int iAxis,
      |                 ^~~~~~~
/usr/include/gdal/ogr_spatialref.h:250:17: note:   candidate expects 3 arguments, 4 provided
make: *** [/opt/R/4.2.3/lib/R/etc/Makeconf:178: gdal.o] Error 1
ERROR: compilation failed for package ‘sf’
* removing ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.2/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/Rtmp8RhXRu/downloaded_packages’

I really appreciate anyone who can help me

I am not an user of Posit Cloud, so please bear with me if my answer does not apply; but for general Ubuntu 20.04 LTS (which is what Focal Fossa stands for) package installation issues it may worth considering the r2u project by Dirk Eddelbuettel - it has binaries (i.e. no install from source) for most if not all R packages.

You need to spend a while in the regular R on Linux world, where installing from source is the norm and takes about forever, to fully appreciate this.

Hi, for me it worked downloading an older source version from CRAN and installing it with

install.packages("sf_1.0-9.tar.gz", repos = NULL, type="source")

Thank you so much!
I can install it now!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.