when trying to install rgeos R cannot find -lgeos - r

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

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.

Cannot install Rgdal (Centos)

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?

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.

Trouble installing nloptr package on R 3.3.0

I can't install the package nloptr 1.0.4 on R 3.3.0. The messages are the following:
> install.packages("nloptr")
Installing package into ‘/Users/fgomesbarros/Library/R/3.3/library
(as ‘lib’ is unspecified)
trying URL 'https://cran.revolutionanalytics.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/octet-stream' length 353942 bytes (345 KB)
==================================================
downloaded 345 KB
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... g++
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 g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for pkg-config... yes
configure: Now testing for NLopt header file.
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... 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 nlopt.h usability... yes
checking nlopt.h presence... yes
checking for nlopt.h... yes
configure: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
/usr/bin/clang++ -I/opt/local/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/opt/local/include -fPIC -pipe -Os -arch x86_64 -stdlib=libstdc++ -c dummy.cpp -o dummy.o
/usr/bin/clang -I/opt/local/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/opt/local/include -fPIC -pipe -Os -arch x86_64 -c nloptr.c -o nloptr.o
/usr/bin/clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/lib -L/opt/local/lib -Wl,-headerpad_max_install_names -o nloptr.so dummy.o nloptr.o -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so':
dlopen(/Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so, 6): Symbol not found: _nlopt_add_equality_mconstraint
Referenced from: /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so
Expected in: flat namespace
in /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/fgomesbarros/Library/R/3.3/library/nloptr’
* restoring previous ‘/Users/fgomesbarros/Library/R/3.3/library/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/rz/dp6vmb39165406h9qv69q60c0000gn/T/RtmpLvLOmn/downloaded_packages’`
My R version is 3.3.0 as you can see below:
> version
_
platform x86_64-apple-darwin12.6.0
arch x86_64
os darwin12.6.0
system x86_64, darwin12.6.0
status
major 3
minor 3.0
year 2016
month 05
day 03
svn rev 70573
language R
version.string R version 3.3.0 (2016-05-03)
nickname Supposedly Educational
Any clues?
I also tried to install in olders versions (2.3.3 and 2.3.4) of R and had the same issue.
Thanks in advance.
I was able to solve the problem on my Mac using
$ brew install nlopt
Looking into the issue I noticed that others had reportedly resolved the issue on Ubuntu using
$ sudo apt-get install libnlopt-dev
Apparently you now need to install it outside of R.
For me, running CentOS, the missing puzzle piece was this:
sudo yum install nlopt-devel
I tried to reinstall the package as a root and it worked! I don't know why.
If you run into this problem with nloptr 1.2.0 and R 3.5.1 on macOS High Sierra, brew install nlopt will fail because of inadequate permissions in /usr/local. The fix:
$ mkdir /usr/local/Frameworks
$ sudo chown -R $(whoami) /usr/local/Frameworks
$ brew install nlopt
In other words, you don't want to change permissions for the entire /usr/local directory. The installation fails when the Homebrew tries to create /usr/local/Framework. So, do it by hand as shown above. Then try again > install.packages("nloptr"). It worked for me.
I had to reinstall R, using the R-CRAN installer and uninstalling the macports package.
It finally worked!
In my case it was the issue of cmake as i am using ubuntu 22. i was installing matlib package of R and then in dependencies i faced this issue which is solved using
sudo apt-get install cmake

Resources