sf installation issues on R4.0 / Ubuntu18.04

Hi, I get stuck when I try to install package sf on R4.0 / Ubuntu 18.04. Anyone facing the same issues?
install.packages("sf")
...
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:... ERROR 1: PROJ: proj_create_from_database: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
ERROR 1: PROJ: proj_create_from_database: SQLite error on SELECT name, coordinate_system_auth_name, coordinate_system_code, geodetic_crs_auth_name, geodetic_crs_code, conversion_auth_name, conversion_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM projected_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
ERROR 1: PROJ: proj_create: unrecognized format / unknown name
ERROR 6: Cannot find coordinate operations from ' to '
no
configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?
ERROR: configuration failed for package ‘sf’

Have you checked that you have the correct versions of the system dependencies installed?

C++11, GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= 4.8.0), sqlite3

How do I check this from Rstudio?

(base) larsrh@pc4225:~$ c++ --version
c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Do I need to have c++ 11?

Well, those are the advertised minimum requirements so I would guess, yes.

Ok, so then it is impossible to install?

Not at all, I have it installed in Ubuntu 18, try with the RStudio package manager to have access to binaries https://packagemanager.rstudio.com/client/#/

Well, this is what I did

How can I upgrade to c++11 ?

I got the same problem. I'm on Ubuntu 18.04 and upgraded R from 3.6 to 4.0.3.

  • installing source package ‘sf’ ...
    ** package ‘sf’ successfully unpacked and MD5 sums checked
    ** using staged installation
    configure: CC: gcc -std=gnu99
    configure: CXX: g++ -std=gnu++11
    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 -std=gnu99
    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 we are using the GNU C compiler... yes
    checking whether gcc -std=gnu99 accepts -g... yes
    checking for gcc -std=gnu99 option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -std=gnu99 -E
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking gdal.h usability... yes
    checking gdal.h presence... 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:... ERROR 1: PROJ: proj_create_from_database: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
    ERROR 1: PROJ: proj_create_from_database: SQLite error on SELECT name, coordinate_system_auth_name, coordinate_system_code, geodetic_crs_auth_name, geodetic_crs_code, conversion_auth_name, conversion_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM projected_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
    ERROR 1: PROJ: proj_create: unrecognized format / unknown name
    ERROR 6: Cannot find coordinate operations from ' to '
    no
    configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?
    ERROR: configuration failed for package ‘sf’

$c++ --version
c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

Missing system dependency. PROJ (>= 4.8.0, Download — PROJ 9.4.0 documentation)

I previously downloaded the PROJ package before my previous post and I am still not being able to download sf. I tried to remove and reinstall the package and nothing change.
Sorry if it is a newbie question, Linux is still very new for me.

$sudo apt-get install proj-bin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
proj-bin is already the newest version (7.0.0-1~bionic0).

It would be great if someone can come up with a solution to this.

Make sure you have these installed in your system

sudo apt install libgdal-dev
sudo apt install gdal-bin
sudo apt install libgeos-dev
sudo apt install libproj-dev

And then install from the RStudio Public Package Manager (as I said before)

options(repos = c(REPO_NAME = "https://packagemanager.rstudio.com/all/__linux__/bionic/latest"))
install.packages("sf")

Thanks, I did what you said, and get the following: There still seem to be problems with PROJ.
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:... ERROR 1: PROJ: proj_create_from_database: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
ERROR 1: PROJ: proj_create_from_database: SQLite error on SELECT name, coordinate_system_auth_name, coordinate_system_code, geodetic_crs_auth_name, geodetic_crs_code, conversion_auth_name, conversion_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM projected_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
ERROR 1: PROJ: proj_create: unrecognized format / unknown name
ERROR 6: Cannot find coordinate operations from ' to '
no
configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?
ERROR: configuration failed for package ‘sf’

  • removing ‘/home/larsrh/R/x86_64-pc-linux-gnu-library/4.0/sf’
    Warning in install.packages :
    installation of package ‘sf’ had non-zero exit status

From the terminal do you get

$ sudo ldconfig -p | grep libproj
        libproj.so.19 (libc6,x86-64) => /lib/x86_64-linux-gnu/libproj.so.19
        libproj.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libproj.so

larsrh@pc4225:~/Dropbox/icedata$ sudo ldconfig -p | grep libproj
libproj.so.19 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libproj.so.19
libproj.so.12 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libproj.so.12
libproj.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libproj.so

Should I remove libproj.so.12 ?

Thanks @andresrcs for the command precision. It seems I had had installed libgdal-dev (3.0.4), gdal-bin(3.0.4), libgeos-dev(3.8.0) and libproj-dev(7.0.0). Changing the repos allowed me to download sf package, but now I cannot import the library in an R session. I got the following error :

>library(sf)
Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/gabriel/R/x86_64-pc-linux-gnu-library/4.0/sf/libs/sf.so':
  libgdal.so.20: cannot open shared object file: No such file or directory

On my side, I got this output:

$ sudo ldconfig -p | grep libproj
	libproj.so.19 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libproj.so.19
	libproj.so.13 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libproj.so.13
	libproj.so.12 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libproj.so.12
	libproj.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libproj.so