Cannot install Rgdal (Centos) - r

Hello I have a problem when I try to install RGDAL. If found other posts with similar problems, but the solutions were always limited to Debian distributions, can you help me on CentOs?
This is the error I have when running the following command in RStudio: > install.packages("rgdal", dependencies = T)
Installing package into ‘/home/dial/R/x86_64-redhat-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.2-13.tar.gz'
Content type 'application/x-gzip' length 1648119 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: CC: gcc -m64 -std=gnu99
configure: CXX: g++ -m64
configure: rgdal: 1.2-13
checking for /usr/bin/svnversion... no
configure: svn revision: 686
checking for gdal-config... /home/dial/anaconda2/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.1.0
checking GDAL version >= 1.6.3... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
followed by a bunch of lines like this one:
/usr/bin/ld: warning: libnetcdf.so.11, needed by /home/dial/anaconda2/lib/libgdal.so, not found (try using -rpath or -rpath-link)
and finally:
collect2: error: ld returned 1 exit status
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/dial/R/x86_64-redhat-linux-gnu-library/3.4/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp8UHPBS/downloaded_packages’
This is done on a server, running on CentOS. I guess the following info might be helpful:
$ gdal-config --version
2.1.0
$ which gdal-config
~/anaconda2/bin/gdal-config
$ gdal-config --libs
-L/home/dial/anaconda2/lib -lgdal
Can you help me with this installation?

Related

MacOS M1: problems with installing sf in R - ERROR: compilation failed for package ‘classInt’; ERROR: configuration failed for package ‘units’

I am working on a MacOS Monterey with an M1 chip and have R 4.2.1 arm64 version (build 554). In the last two months I have come across an issue with install.package("sf") and others but will start with sf. When it asks to install from sources and I enter "No", the library won't load so I enter "Yes" and it gets an error (full error below).
ERROR: compilation failed for package ‘classInt’
ERROR: configuration failed for package ‘units’
I have redownloaded the sf, classInt, units, and udunits2 packages from this link (https://cran.r-project.org/web/packages/available_packages_by_name.html), choosing the r re-release arm64 versions and it still doesn't work.
I tried following along with this https://github.com/r-spatial/sf/issues/1542 until the .configure command was not found in the terminal.
I then tried: brew install udunits in the Mac terminal using Homebrew and the error did not change.
I installed sf defining the library with udunits2 and it didn't work:
install.packages("sf", configure.args = "--/Library/Frameworks/R.framework/Versions/4.2/Resources/library/udunits2")
I've spent over a full day troubleshooting and I'm not sure what to try next.
Any help is appreciated!
> install.packages("sf", configure.args = "--/Library/Frameworks/R.framework/Versions/4.2/Resources/library/udunits2")
also installing the dependencies ‘classInt’, ‘units’
Packages which are only available in source form, and may need compilation of C/C++/Fortran: ‘classInt’ ‘units’ ‘sf’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source packages ‘classInt’, ‘units’, ‘sf’
trying URL 'https://packagemanager.rstudio.com/all/latest/src/contrib/classInt_0.4-7.tar.gz'
Content type 'binary/octet-stream' length 440183 bytes (429 KB)
==================================================
downloaded 429 KB
trying URL 'https://packagemanager.rstudio.com/all/latest/src/contrib/units_0.8-0.tar.gz'
Content type 'binary/octet-stream' length 864506 bytes (844 KB)
==================================================
downloaded 844 KB
trying URL 'https://packagemanager.rstudio.com/all/latest/src/contrib/sf_1.0-8.tar.gz'
Content type 'binary/octet-stream' length 3532612 bytes (3.4 MB)
==================================================
downloaded 3.4 MB
* installing *source* package ‘classInt’ ...
** package ‘classInt’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/opt/R/arm64/bin/gfortran -mtune=native -fno-optimize-sibling-calls -fPIC -Wall -g -O2 -c fish1.f -o fish1.o
make: /opt/R/arm64/bin/gfortran: No such file or directory
make: *** [fish1.o] Error 1
ERROR: compilation failed for package ‘classInt’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/classInt’
Warning in install.packages :
installation of package ‘classInt’ had non-zero exit status
* installing *source* package ‘units’ ...
** package ‘units’ successfully unpacked and MD5 sums checked
** using staged installation
configure: units: 0.8-0
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 clang++ -arch arm64 -std=gnu++14 accepts -g... yes
checking how to run the C++ preprocessor... clang++ -arch arm64 -std=gnu++14 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
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 for stdbool.h that conforms to C99... no
checking for _Bool... no
checking for error_at_line... no
checking for gcc... clang -arch arm64
checking whether we are using the GNU C compiler... yes
checking whether clang -arch arm64 accepts -g... yes
checking for clang -arch arm64 option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in `/private/var/folders/4k/f9g3wpqj2tv7rvsmhjtkbdl80000gn/T/Rtmp6uUpFo/R.INSTALL1845f210c2dbd/units':
configure: error:
--------------------------------------------------------------------------------
Configuration failed because libudunits2.so was not found. Try installing:
* deb: libudunits2-dev (Debian, Ubuntu, ...)
* rpm: udunits2-devel (Fedora, EPEL, ...)
* brew: udunits (OSX)
If udunits2 is already installed in a non-standard location, use:
--configure-args='--with-udunits2-lib=/usr/local/lib'
if the library was not found, and/or:
--configure-args='--with-udunits2-include=/usr/include/udunits2'
if the header was not found, replacing paths with appropriate values.
You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘units’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/units’
Warning in install.packages :
installation of package ‘units’ had non-zero exit status
ERROR: dependencies ‘classInt’, ‘units’ are not available for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/4k/f9g3wpqj2tv7rvsmhjtkbdl80000gn/T/RtmpPnpNin/downloaded_packages```
After installing gdal with homebrew, I used the link #wkl sent and the code install.packages('sf', configure.args = '--with-proj-include=/opt/homebrew/include/ --with-proj-lib=/opt/homebrew/lib/', configure.vars = 'GDAL_DATA=/opt/homebrew/opt/gdal/share/gdal/')
I am still having problems with other packages but sf loaded.

Upgrade GEOS version on shiny apps.io

It seems that the current version of GEOS available on shinyapps.io is not at the right level.
This is the error message I am getting when trying to deploy my app:
** package ‘lwgeom’ successfully unpacked and MD5 sums checked
** using staged installation configure: CC: gcc configure: CXX: g++ -std=gnu++11 configure: pkg-config proj exists, will use it configure: PROJ: 4.9.2 checking for pj_init_plus in -lproj... yes
checking PROJ:
epsg found and readable... yes configure: POSTGIS_PROJ_VERSION: 49
checking for geos-config... /usr/bin/geos-config checking geos-config
usability... yes configure: GEOS: 3.5.1 checking GEOS version >=
3.6.0... no
configure: error: upgrade GEOS to 3.6.0 or later
ERROR: configuration failed for package ‘lwgeom’
removing ‘/opt/R/4.0.0/lib/R/library/lwgeom’
Is there anything I could do to by-pass this problem waiting for an update on the shiny apps side?
Thank you in advance.

when trying to install rgeos R cannot find -lgeos

I am trying to install rgeos in R 3.5.1 running in ubuntu 16.04. When I run
install.packages("rgeos")
I get the following message:
* installing *source* package ‘rgeos’ ...
** package ‘rgeos’ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgeos: 0.4-1
checking for /usr/bin/svnversion... yes
configure: svn revision: 579
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS version: 3.5.1
checking geos version at least 3.2.0... yes
checking geos-config clibs... yes
checking geos_c.h presence and usability... yes
checking geos: linking with libgeos_c... no
/usr/bin/ld: cannot find -lgeos
collect2: error: ld returned 1 exit status
configure: Install failure: compilation and/or linkage problems.
configure: error: initGEOS_r not found in libgeos_c.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/3.5/rgeos’
Warning in install.packages :
installation of package ‘rgeos’ had non-zero exit status
I tried installing geospatial libraries
sudo apt-get install binutils libproj-dev gdal-bin
but it didn't help
Any help would be apprecieated
Same problem with R 3.5.1. This fixed the issue
sudo apt install libgeos++-dev

libgdal.so.20 issue centos rgdal

Can someone help me to understanding what is the problem of rgdal ?
I installed gdal 2 for centos 6 64 bits but i didn't succeed to install rgdal.
I tried to figure out what is the issue but i didn't found anything useful on the internet .
this is Rstudio-server console:
install.packages("rgdal")
Installing package into ‘/home/admin/R/x86_64-redhat-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
essai de l'URL 'https://cran.rstudio.com/src/contrib/rgdal_1.2-18.tar.gz'
Content type 'application/x-gzip' length 1650578 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ correctement décompressé et sommes MD5 vérifiées
configure: CC: gcc -m64 -std=gnu99
configure: CXX: g++ -m64
configure: rgdal: 1.2-18
checking for /usr/bin/svnversion... yes
configure: svn revision: 718
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.3
checking GDAL version >= 1.6.3... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/local/share/gdal/pcs.csv readable... yes
configure: -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack- protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic -fPIC -I/usr/local/include
checking proj_api.h presence and usability... yes
./proj_conf_test1: error while loading shared libraries: libgdal.so.20: cannot open shared object file: No such file or directory
checking PROJ.4 version: ... < 4.8.0
./configure: line 2030: test: -eq: unary operator expected
./configure: line 2035: test: -ge: unary operator expected
./configure: line 2063: test: -ge: unary operator expected
./proj_conf_test2: error while loading shared libraries: libgdal.so.20: cannot open shared object file: No such file or directory
checking PROJ.4: epsg found and readable... yes
./configure: line 2138: test: -ge: unary operator expected
./proj_conf_test3: error while loading shared libraries: libgdal.so.20: cannot open shared object file: No such file or directory
checking PROJ.4: conus found and readable... yes
configure: Package CPP flags: -I/usr/local/include
configure: Package LIBS: -L/usr/local/lib -lgdal -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
ogr_geom.cpp:39: attention : ‘mp_count_k0’ may be used uninitialized in this function
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
converting help for package ‘rgdal’
finding HTML links ... fini
CRS-class html
...
closeDataset-methods html
displayDataset html
llgrid html
Rd warning: /tmp/RtmpTT9ff6/R.INSTALL19d55c4b60f4/rgdal/man/llgrid.Rd:11: missing file link ‘Spatial’
Rd warning: /tmp/RtmpTT9ff6/R.INSTALL19d55c4b60f4/rgdal/man/llgrid.Rd:16: missing file link ‘gridat’
Rd warning: /tmp/RtmpTT9ff6/R.INSTALL19d55c4b60f4/rgdal/man/llgrid.Rd:17: missing file link ‘gridat’
make_EPSG html
nor2k html
projInfo html
project html
readGDAL html
Rd warning: /tmp/RtmpTT9ff6/R.INSTALL19d55c4b60f4/rgdal/man/readGDAL.Rd:136: missing file link ‘flipVertical’
readOGR html
showWKT html
spTransform-methods html
wrappers html
writeOGR html
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
impossible de charger l'objet partagé '/home/admin/R/x86_64-redhat- linux-gnu-library/3.4/rgdal/libs/rgdal.so':
libgdal.so.20: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type
Erreur : le chargement a échoué
Exécution arrêtée
ERROR: loading failed
* removing ‘/home/admin/R/x86_64-redhat-linux-gnu-library/3.4/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpBon7nM/downloaded_packages’
I tried to install dependencies of gdal and copying libgdal.so.20 to /user/lib64/ogdi whithout any success !*
Thank you for you help
The solution was so simple !
CentOS can't find these libraries and I just copied these libraries to 64 folder .
cp /usr/local/lib/libgdal.so.20* /usr/lib64/
and everything work like a magic !

Problems installing R package "devtools" on Ubuntu 16.04 (Xenial)

I installed RStudio and R on Ubuntu 16.04 (Xenial) Linux:
user#machine:~/.Rlibs$ R --version
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
My problem is that I am not able to install package "devtools". I get a series of errors and all my attempts to install required dependencies failed so far. It seems that packages cannot be found even though they are installed.
I would be really grateful for any help!
The errors occur when trying to install the "devtools" package in RStudio or using the R console:
install.packages("devtools")
These are the errors I am getting (leaving out the download output):
* installing *source* package ‘mime’ ...
** package ‘mime’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c rawmatch.c -o rawmatch.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:132: recipe for target 'rawmatch.o' failed
make: *** [rawmatch.o] Error 1
ERROR: compilation failed for package ‘mime’
* removing ‘/home/user/.Rlibs/mime’
Warning in install.packages :
installation of package ‘mime’ had non-zero exit status
* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
* deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
* rpm: libcurl-devel (Fedora, CentOS, RHEL)
* csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘curl’
* removing ‘/home/user/.Rlibs/curl’
Warning in install.packages :
installation of package ‘curl’ had non-zero exit status
* installing *source* package ‘openssl’ ...
** package ‘openssl’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-lssl -lcrypto
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
* deb: libssl-dev (Debian, Ubuntu, etc)
* rpm: openssl-devel (Fedora, CentOS, RHEL)
* csw: libssl_dev (Solaris)
* brew: openssl (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘openssl’
* removing ‘/home/user/.Rlibs/openssl’
Warning in install.packages :
installation of package ‘openssl’ had non-zero exit status
* installing *source* package ‘digest’ ...
** package ‘digest’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c aes.c -o aes.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:132: recipe for target 'aes.o' failed
make: *** [aes.o] Error 1
ERROR: compilation failed for package ‘digest’
* removing ‘/home/user/.Rlibs/digest’
Warning in install.packages :
installation of package ‘digest’ had non-zero exit status
* installing *source* package ‘jsonlite’ ...
** package ‘jsonlite’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -Iyajl/api -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c base64.c -o base64.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:132: recipe for target 'base64.o' failed
make: *** [base64.o] Error 1
ERROR: compilation failed for package ‘jsonlite’
* removing ‘/home/user/.Rlibs/jsonlite’
Warning in install.packages :
installation of package ‘jsonlite’ had non-zero exit status
* installing *source* package ‘git2r’ ...
** package ‘git2r’ successfully unpacked and MD5 sums checked
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
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 we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing inflate... no
configure: error: in `/tmp/RtmpMyvGHt/R.INSTALL4c4a1e9555fc/git2r':
configure: error:
---------------------------------------------
The zlib library that is required to build
git2r was not found.
Please install:
zlib1g-dev (package on e.g. Debian and Ubuntu)
zlib-devel (package on e.g. Fedora, CentOS and RHEL)
and try again.
If the zlib library is installed on your
system but the git2r configuration is
unable to find it, you can specify the
include and lib path to zlib with:
R CMD INSTALL --configure-args='--with-zlib-include=INCLUDE_PATH --with-zlib-lib=LIB_PATH' git2r
---------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘git2r’
* removing ‘/home/user/.Rlibs/git2r’
Warning in install.packages :
installation of package ‘git2r’ had non-zero exit status
ERROR: dependencies ‘jsonlite’, ‘mime’, ‘curl’, ‘openssl’ are not available for package ‘httr’
* removing ‘/home/user/.Rlibs/httr’
Warning in install.packages :
installation of package ‘httr’ had non-zero exit status
ERROR: dependency ‘digest’ is not available for package ‘memoise’
* removing ‘/home/user/.Rlibs/memoise’
Warning in install.packages :
installation of package ‘memoise’ had non-zero exit status
ERROR: dependencies ‘httr’, ‘memoise’, ‘digest’, ‘jsonlite’, ‘git2r’ are not available for package ‘devtools’
* removing ‘/home/user/.Rlibs/devtools’
Warning in install.packages :
installation of package ‘devtools’ had non-zero exit status
I noticed the following error:
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
I experienced the same issue when I wanted to use an outdated version of gcc (specifically, 4.8) to resolve some compatibility issues in one of my projects. The compiler flags "-Wdate-time" and "-fstack-protector-strong" are not available in older gcc releases. A similar flag "-fstack-protector-all" is available in some older gcc releases though.
To wrap up, this error messages is due to the fact that the developers expected an up-to-date gcc and used compiler flags for that up-to-date gcc version, but the gcc installed in your system was outdated.
Hope that helps other who might run into this issue in the future.

Resources