RcppArmadillo: failing to install on Ubuntu16.04 - r

I am trying to install Rcpp on Ubuntu. Here are some environment details:
R version:3.4.0
g++ --version: Ubuntu 5.4.0-6ubuntu1~16.04.4
If I have a blank Makevars file, RcppArmadillo can be installed but with some warnings about OpenMp
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from RcppArmadillo.cpp:22:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from RcppExports.cpp:4:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fastLm.cpp -o fastLm.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from fastLm.cpp:22:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RcppArmadillo)
After I added PKG_CXXFLAGS=-std=c++11 to Makevars, I got a error message as following:
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -std=c++11 -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppArmadillo.cpp -o RcppArmadillo.o
RcppArmadillo.cpp:22:27: fatal error: RcppArmadillo.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:168: recipe for target 'RcppArmadillo.o' failed
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo’
* restoring previous ‘/home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo’
Warning in install.packages :
installation of package ‘RcppArmadillo’ had non-zero exit status
The wield thing is that when I tried to re-install RcppArmadillo on my mac(10.11), the same problem occurred. Could anybody enlighten me?

This is 16.10 which I have here at hone, if you wish I can repeat it at work tomorrow with 16.04:
edd#bud:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
edd#bud:~$ Rscript -e 'install.packages("RcppArmadillo")'
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RcppArmadillo_0.7.960.1.1.tar.gz'
Content type 'application/x-gzip' length 1115539 bytes (1.1 MB)
==================================================
downloaded 1.1 MB
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
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 ccache g++ accepts -g... yes
checking how to run the C++ preprocessor... ccache g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether ccache g++ accepts -g... (cached) yes
checking whether g++ version is sufficient... (6.2.0) yes
checking LAPACK_LIBS... system LAPACK found
checking for OpenMP... found
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloLapack.h
** libs
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c RcppArmadillo.cpp -o RcppArmadillo.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c RcppExports.cpp -o RcppExports.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c fastLm.cpp -o fastLm.o
ccache g++ -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/RcppArmadillo/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RcppArmadillo)
The downloaded source packages are in
‘/tmp/Rtmp2hQNrn/downloaded_packages’
edd#bud:~$
That I usee ccache is not material. This. Just. Works.

Related

Some R packages cannot be installed Ubuntu 20.04: No such file or directory - unary operator expected - C++ compiler cannot create executables

I've been using R and Rstudio for a while now on a PC with ubuntu 20.04 and have always been able to install whatever package I need. In fact, I can still install most packages, both via install.packages and BiocManager. I have installed R-base-dev and can install most packages from CRAN just fine.
The other day I wanted to install the package "NormalyzerDE" and was also asked if I wanted to update two old packages, "nloptr" and "dplyr".
As you can see below, "NormalyzerDE" fails because the first two dependencies fail, one with the error:
* installing *source* package ‘terra’ ...
** package ‘terra’ successfully unpacked and MD5 sums checked
** using staged installation
Rscript execution error: No such file or directory
./configure: line 2060: test: =: unary operator expected
./configure: line 2064: test: too many arguments
./configure: line 2067: test: too many arguments
configure: CC: gcc
configure: CXX: g++ -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘terra’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/terra’
And the other with the error:
* installing *source* package ‘polyclip’ ...
** package ‘polyclip’ successfully unpacked and MD5 sums checked
** using staged installation
Rscript execution error: No such file or directory
compiling under C++11
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpL9dO8R/R.INSTALL683312b8a63e4/polyclip':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘polyclip’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/polyclip’
Finally, "dplyr" updates just fine, but "nloptr" fails with the error:
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
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 g++ -std=gnu++14 accepts -g... yes
checking for g++ -std=gnu++14 option to enable C++11 features... none needed
checking how to run the C++ preprocessor... g++ -std=gnu++14 -E
checking whether the compiler supports GNU C++... (cached) yes
checking whether g++ -std=gnu++14 accepts -g... (cached) yes
checking for g++ -std=gnu++14 option to enable C++11 features... (cached) none needed
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... yes
checking for pkg-config checking NLopt version... insufficient: NLopt 2.7.0 or later is preferred.
checking for cmake... /usr/bin/cmake
Rscript execution error: No such file or directory
using NLopt via local cmake build on
Rscript execution error: No such file or directory
set CMAKE_BIN=/usr/bin/cmake
Rscript execution error: No such file or directory
mv: cannot stat 'nlopt-2.7.1': No such file or directory
set CC=gcc
set CFLAGS= -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
set CXX=g++
set CXXFLAGS=-std=gnu++11 -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
set LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro
Rscript execution error: No such file or directory
Rscript execution error: No such file or directory
CMake Error: The source directory "/tmp/RtmpU9IvGD/R.INSTALL684e27f439022/nloptr/src/nlopt-src" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.
mv: cannot stat 'nlopt/lib*': No such file or directory
cp: cannot stat 'nlopt/include/*': No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c init_nloptr.c -o init_nloptr.o
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -llapack -lblas -lgfortran -lm -lquadmath nlopt/lib/libnlopt.a -L/usr/lib/R/lib -lR
g++: error: nlopt/lib/libnlopt.a: No such file or directory
make: *** [/usr/share/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/nloptr’
* restoring previous ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/nloptr’
I've looked around quite a bit for the answer and have made sure to have R-base-dev and build-essentials installed and have tried to set CMAKE_BIN=/usr/bin/cmake in the bash terminal, but nothing seems to be working and I can't find any answers online.
Does anyone know what to do?
Full output:
> BiocManager::install("NormalyzerDE")
'getOption("repos")' replaces Bioconductor standard repositories, see '?repositories' for details
replacement repositories:
CRAN: https://cloud.r-project.org
Bioconductor version 3.15 (BiocManager 1.30.18), R 4.2.1 (2022-06-23)
Installing package(s) 'NormalyzerDE'
also installing the dependencies ‘terra’, ‘polyclip’, ‘raster’, ‘ggforce’
trying URL 'https://cloud.r-project.org/src/contrib/terra_1.6-7.tar.gz'
Content type 'application/x-gzip' length 689703 bytes (673 KB)
==================================================
downloaded 673 KB
trying URL 'https://cloud.r-project.org/src/contrib/polyclip_1.10-0.tar.gz'
Content type 'application/x-gzip' length 79619 bytes (77 KB)
==================================================
downloaded 77 KB
trying URL 'https://cloud.r-project.org/src/contrib/raster_3.5-29.tar.gz'
Content type 'application/x-gzip' length 577629 bytes (564 KB)
==================================================
downloaded 564 KB
trying URL 'https://cloud.r-project.org/src/contrib/ggforce_0.3.4.tar.gz'
Content type 'application/x-gzip' length 860656 bytes (840 KB)
==================================================
downloaded 840 KB
trying URL 'https://bioconductor.org/packages/3.15/bioc/src/contrib/NormalyzerDE_1.14.0.tar.gz'
Content type 'application/x-gzip' length 1085633 bytes (1.0 MB)
==================================================
downloaded 1.0 MB
* installing *source* package ‘terra’ ...
** package ‘terra’ successfully unpacked and MD5 sums checked
** using staged installation
Rscript execution error: No such file or directory
./configure: line 2060: test: =: unary operator expected
./configure: line 2064: test: too many arguments
./configure: line 2067: test: too many arguments
configure: CC: gcc
configure: CXX: g++ -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘terra’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/terra’
* installing *source* package ‘polyclip’ ...
** package ‘polyclip’ successfully unpacked and MD5 sums checked
** using staged installation
Rscript execution error: No such file or directory
compiling under C++11
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpL9dO8R/R.INSTALL683312b8a63e4/polyclip':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘polyclip’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/polyclip’
ERROR: dependency ‘terra’ is not available for package ‘raster’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/raster’
ERROR: dependency ‘polyclip’ is not available for package ‘ggforce’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/ggforce’
ERROR: dependencies ‘raster’, ‘ggforce’ are not available for package ‘NormalyzerDE’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/NormalyzerDE’
The downloaded source packages are in
‘/tmp/Rtmppq0Ahj/downloaded_packages’
Installation paths not writeable, unable to update packages
path: /usr/lib/R/library
packages:
MASS, spatial
path: /usr/lib/R/site-library
packages:
gtable, rlang, tibble
Old packages: 'dplyr', 'nloptr'
Update all/some/none? [a/s/n]:
a
trying URL 'https://cloud.r-project.org/src/contrib/dplyr_1.0.10.tar.gz'
Content type 'application/x-gzip' length 884984 bytes (864 KB)
==================================================
downloaded 864 KB
trying URL 'https://cloud.r-project.org/src/contrib/nloptr_2.0.3.tar.gz'
Content type 'application/x-gzip' length 2219877 bytes (2.1 MB)
==================================================
downloaded 2.1 MB
* installing *source* package ‘dplyr’ ...
** package ‘dplyr’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c chop.cpp -o chop.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c filter.cpp -o filter.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c funs.cpp -o funs.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c group_by.cpp -o group_by.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c group_data.cpp -o group_data.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c imports.cpp -o imports.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c init.cpp -o init.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c mask.cpp -o mask.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c mutate.cpp -o mutate.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c slice.cpp -o slice.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c summarise.cpp -o summarise.o
g++ -std=gnu++14 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o dplyr.so chop.o filter.o funs.o group_by.o group_data.o imports.o init.o mask.o mutate.o slice.o summarise.o -L/usr/lib/R/lib -lR
installing to /home/emil/R/x86_64-pc-linux-gnu-library/4.2/00LOCK-dplyr/00new/dplyr/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** 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 (dplyr)
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
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 g++ -std=gnu++14 accepts -g... yes
checking for g++ -std=gnu++14 option to enable C++11 features... none needed
checking how to run the C++ preprocessor... g++ -std=gnu++14 -E
checking whether the compiler supports GNU C++... (cached) yes
checking whether g++ -std=gnu++14 accepts -g... (cached) yes
checking for g++ -std=gnu++14 option to enable C++11 features... (cached) none needed
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... yes
checking for pkg-config checking NLopt version... insufficient: NLopt 2.7.0 or later is preferred.
checking for cmake... /usr/bin/cmake
Rscript execution error: No such file or directory
using NLopt via local cmake build on
Rscript execution error: No such file or directory
set CMAKE_BIN=/usr/bin/cmake
Rscript execution error: No such file or directory
mv: cannot stat 'nlopt-2.7.1': No such file or directory
set CC=gcc
set CFLAGS= -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
set CXX=g++
set CXXFLAGS=-std=gnu++11 -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
set LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro
Rscript execution error: No such file or directory
Rscript execution error: No such file or directory
CMake Error: The source directory "/tmp/RtmpU9IvGD/R.INSTALL684e27f439022/nloptr/src/nlopt-src" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.
mv: cannot stat 'nlopt/lib*': No such file or directory
cp: cannot stat 'nlopt/include/*': No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c init_nloptr.c -o init_nloptr.o
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -llapack -lblas -lgfortran -lm -lquadmath nlopt/lib/libnlopt.a -L/usr/lib/R/lib -lR
g++: error: nlopt/lib/libnlopt.a: No such file or directory
make: *** [/usr/share/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/nloptr’
* restoring previous ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/nloptr’
The downloaded source packages are in
‘/tmp/Rtmppq0Ahj/downloaded_packages’
Warning messages:
1: In install.packages(...) :
installation of package ‘terra’ had non-zero exit status
2: In install.packages(...) :
installation of package ‘polyclip’ had non-zero exit status
3: In install.packages(...) :
installation of package ‘raster’ had non-zero exit status
4: In install.packages(...) :
installation of package ‘ggforce’ had non-zero exit status
5: In install.packages(...) :
installation of package ‘NormalyzerDE’ had non-zero exit status
6: In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, :
installation of package ‘nloptr’ had non-zero exit status
UPDATE
Thanks for the fast replies!
which cmake yields /usr/bin/cmake (the same is true for make) and ls -la /usr/bin/cmake yields -rwxr-xr-x 1 root root 5944072 feb 6 2020 /usr/bin/cmake. Changing the ownership with chown to me did not solve the issue. gdal-config was indeed not installed and after installing it, terra installs properly! (I also had to install libobdc1 and unixobdc-dev to make it work). However, polyclip and nloptr still does not install properly. Something seems to be wrong with the c++ compiler?
UPDATED OUTPUT
> BiocManager::install("NormalyzerDE")
'getOption("repos")' replaces Bioconductor standard repositories, see '?repositories' for details
replacement repositories:
CRAN: https://cloud.r-project.org
Bioconductor version 3.15 (BiocManager 1.30.18), R 4.2.1 (2022-06-23)
Installing package(s) 'NormalyzerDE'
also installing the dependencies ‘polyclip’, ‘ggforce’
trying URL 'https://cloud.r-project.org/src/contrib/polyclip_1.10-0.tar.gz'
Content type 'application/x-gzip' length 79619 bytes (77 KB)
==================================================
downloaded 77 KB
trying URL 'https://cloud.r-project.org/src/contrib/ggforce_0.3.4.tar.gz'
Content type 'application/x-gzip' length 860656 bytes (840 KB)
==================================================
downloaded 840 KB
trying URL 'https://bioconductor.org/packages/3.15/bioc/src/contrib/NormalyzerDE_1.14.0.tar.gz'
Content type 'application/x-gzip' length 1085633 bytes (1.0 MB)
==================================================
downloaded 1.0 MB
* installing *source* package ‘polyclip’ ...
** package ‘polyclip’ successfully unpacked and MD5 sums checked
** using staged installation
Rscript execution error: No such file or directory
compiling under C++11
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpULM1t8/R.INSTALLe17e7b8b5788/polyclip':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘polyclip’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/polyclip’
ERROR: dependency ‘polyclip’ is not available for package ‘ggforce’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/ggforce’
ERROR: dependency ‘ggforce’ is not available for package ‘NormalyzerDE’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/NormalyzerDE’
The downloaded source packages are in
‘/tmp/RtmpAV94Sg/downloaded_packages’
Installation paths not writeable, unable to update packages
path: /usr/lib/R/library
packages:
MASS, spatial
path: /usr/lib/R/site-library
packages:
gtable, rlang, tibble
Old packages: 'nloptr'
Update all/some/none? [a/s/n]:
a
trying URL 'https://cloud.r-project.org/src/contrib/nloptr_2.0.3.tar.gz'
Content type 'application/x-gzip' length 2219877 bytes (2.1 MB)
==================================================
downloaded 2.1 MB
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
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 g++ -std=gnu++14 accepts -g... yes
checking for g++ -std=gnu++14 option to enable C++11 features... none needed
checking how to run the C++ preprocessor... g++ -std=gnu++14 -E
checking whether the compiler supports GNU C++... (cached) yes
checking whether g++ -std=gnu++14 accepts -g... (cached) yes
checking for g++ -std=gnu++14 option to enable C++11 features... (cached) none needed
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... yes
checking for pkg-config checking NLopt version... insufficient: NLopt 2.7.0 or later is preferred.
checking for cmake... /usr/bin/cmake
Rscript execution error: No such file or directory
using NLopt via local cmake build on
Rscript execution error: No such file or directory
set CMAKE_BIN=/usr/bin/cmake
Rscript execution error: No such file or directory
mv: cannot stat 'nlopt-2.7.1': No such file or directory
set CC=gcc
set CFLAGS= -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
set CXX=g++
set CXXFLAGS=-std=gnu++11 -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
set LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro
Rscript execution error: No such file or directory
Rscript execution error: No such file or directory
CMake Error: The source directory "/tmp/Rtmpcdneyf/R.INSTALLe3b819d8bc7f/nloptr/src/nlopt-src" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.
mv: cannot stat 'nlopt/lib*': No such file or directory
cp: cannot stat 'nlopt/include/*': No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c init_nloptr.c -o init_nloptr.o
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/emil/R/x86_64-pc-linux-gnu-library/4.2/testthat/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -llapack -lblas -lgfortran -lm -lquadmath nlopt/lib/libnlopt.a -L/usr/lib/R/lib -lR
g++: error: nlopt/lib/libnlopt.a: No such file or directory
make: *** [/usr/share/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/nloptr’
* restoring previous ‘/home/emil/R/x86_64-pc-linux-gnu-library/4.2/nloptr’
The downloaded source packages are in
‘/tmp/RtmpAV94Sg/downloaded_packages’
Warning messages:
1: In install.packages(...) :
installation of package ‘polyclip’ had non-zero exit status
2: In install.packages(...) :
installation of package ‘ggforce’ had non-zero exit status
3: In install.packages(...) :
installation of package ‘NormalyzerDE’ had non-zero exit status
4: In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, :
installation of package ‘nloptr’ had non-zero exit status

Can't install package lwgeom in R 3.5.2

I'm trying to install, in R 3.5.2 (under Debian 9), package lwgeom, which is a dependency of sf, which is a dependency of spider, the final desired package. But I got a few errors:
> install.packages('lwgeom',depend=T)
Installing package into ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependency ‘sf’
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.7-2.tar.gz'
Content type 'application/x-gzip' length 8330773 bytes (7.9 MB)
==================================================
downloaded 7.9 MB
trying URL 'https://cloud.r-project.org/src/contrib/lwgeom_0.1-5.tar.gz'
Content type 'application/x-gzip' length 439764 bytes (429 KB)
==================================================
downloaded 429 KB
* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
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: 2.1.2
checking GDAL version >= 2.0.0... 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/2.1/pcs.csv readable... yes
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: pkg-config proj exists, will use it
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
configure: PROJ: 4.9.3
checking for pj_init_plus in -lproj... yes
checking PROJ: epsg found and readable... yes
checking PROJ: conus found and readable... yes
checking for geos-config... /usr/local/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.7.1
checking GEOS version >= 3.4.0... yes
checking geos_c.h usability... yes
checking geos_c.h presence... yes
checking for geos_c.h... yes
checking geos: linking with -L/usr/local/lib -lgeos_c... yes
configure: Package CPP flags: -I/usr/include/gdal -I/usr/local/include
configure: Package LIBS: -lproj -L/usr/lib -lgdal -L/usr/local/lib -lgeos_c
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bbox.cpp -o bbox.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal.cpp -o gdal.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_geom.cpp -o gdal_geom.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_read.cpp -o gdal_read.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_utils.cpp -o gdal_utils.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_write.cpp -o gdal_write.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c geos.cpp -o geos.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c hex.cpp -o hex.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c polygonize.cpp -o polygonize.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c proj.cpp -o proj.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c raster2sf.cpp -o raster2sf.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c sfg.cpp -o sfg.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c signed_area.cpp -o signed_area.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c stars.cpp -o stars.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c wkb.cpp -o wkb.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-z,relro -o sf.so RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o gdal_utils.o gdal_write.o geos.o hex.o polygonize.o proj.o raster2sf.o sfg.o signed_area.o stars.o wkb.o -lproj -L/usr/lib -lgdal -L/usr/local/lib -lgeos_c -L/usr/lib/R/lib -lR
installing to /home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/sf/libs
** R
** data
** demo
** inst
** byte-compile and prepare package for lazy loading
in method for ‘dbWriteTable’ with signature ‘"PostgreSQLConnection","character","sf"’: no definition for class “PostgreSQLConnection”
in method for ‘dbDataType’ with signature ‘"PostgreSQLConnection","sf"’: no definition for class “PostgreSQLConnection”
in method for ‘coerce’ with signature ‘"Spatial","sf"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"Spatial","sfc"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"sf","Spatial"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"sfc","Spatial"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"XY","Spatial"’: no definition for class “Spatial”
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/sf/libs/sf.so':
/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/sf/libs/sf.so: undefined symbol: GEOSFrechetDistanceDensify_r
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status
ERROR: dependency ‘sf’ is not available for package ‘lwgeom’
* removing ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/lwgeom’
Warning in install.packages :
installation of package ‘lwgeom’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmptKPuTu/downloaded_packages’
The lines with errors are:
in method for ‘dbWriteTable’ with signature ‘"PostgreSQLConnection","character","sf"’: no definition for class “PostgreSQLConnection”
in method for ‘dbDataType’ with signature ‘"PostgreSQLConnection","sf"’: no definition for class “PostgreSQLConnection”
I installed the packages RSQLite and RPostgreSQL, but this didn't solved it.
in method for ‘coerce’ with signature ‘"Spatial","sf"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"Spatial","sfc"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"sf","Spatial"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"sfc","Spatial"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"XY","Spatial"’: no definition for class “Spatial”
I have no idea how to solve these, but I have the following packages installed in Debian:
libgdal-dev is already the newest version (2.1.2+dfsg-5).
libgeos-dev is already the newest version (3.5.1-3).
libproj-dev is already the newest version (4.9.3-1).
libudunits2-dev is already the newest version (2.2.20-1+b1).
The last important error:
ERROR: dependency ‘sf’ is not available for package ‘lwgeom’
But if I try to install sf, I got the following error:
> install.packages('sf',depend=T)
Installing package into ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘tmaptools’, ‘lwgeom’, ‘mapview’, ‘stars’, ‘tmap’
trying URL 'https://cloud.r-project.org/src/contrib/tmaptools_2.0-1.tar.gz'
Content type 'application/x-gzip' length 84292 bytes (82 KB)
==================================================
downloaded 82 KB
trying URL 'https://cloud.r-project.org/src/contrib/lwgeom_0.1-5.tar.gz'
Content type 'application/x-gzip' length 439764 bytes (429 KB)
==================================================
downloaded 429 KB
trying URL 'https://cloud.r-project.org/src/contrib/mapview_2.6.3.tar.gz'
Content type 'application/x-gzip' length 2016015 bytes (1.9 MB)
==================================================
downloaded 1.9 MB
trying URL 'https://cloud.r-project.org/src/contrib/stars_0.2-0.tar.gz'
Content type 'application/x-gzip' length 5999356 bytes (5.7 MB)
==================================================
downloaded 5.7 MB
trying URL 'https://cloud.r-project.org/src/contrib/tmap_2.2.tar.gz'
Content type 'application/x-gzip' length 2900602 bytes (2.8 MB)
==================================================
downloaded 2.8 MB
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.7-2.tar.gz'
Content type 'application/x-gzip' length 8330773 bytes (7.9 MB)
==================================================
downloaded 7.9 MB
* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
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: 2.1.2
checking GDAL version >= 2.0.0... 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/2.1/pcs.csv readable... yes
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: pkg-config proj exists, will use it
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
configure: PROJ: 4.9.3
checking for pj_init_plus in -lproj... yes
checking PROJ: epsg found and readable... yes
checking PROJ: conus found and readable... yes
checking for geos-config... /usr/local/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.7.1
checking GEOS version >= 3.4.0... yes
checking geos_c.h usability... yes
checking geos_c.h presence... yes
checking for geos_c.h... yes
checking geos: linking with -L/usr/local/lib -lgeos_c... yes
configure: Package CPP flags: -I/usr/include/gdal -I/usr/local/include
configure: Package LIBS: -lproj -L/usr/lib -lgdal -L/usr/local/lib -lgeos_c
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bbox.cpp -o bbox.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal.cpp -o gdal.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_geom.cpp -o gdal_geom.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_read.cpp -o gdal_read.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_utils.cpp -o gdal_utils.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_write.cpp -o gdal_write.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c geos.cpp -o geos.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c hex.cpp -o hex.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c polygonize.cpp -o polygonize.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c proj.cpp -o proj.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c raster2sf.cpp -o raster2sf.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c sfg.cpp -o sfg.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c signed_area.cpp -o signed_area.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c stars.cpp -o stars.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c wkb.cpp -o wkb.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-z,relro -o sf.so RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o gdal_utils.o gdal_write.o geos.o hex.o polygonize.o proj.o raster2sf.o sfg.o signed_area.o stars.o wkb.o -lproj -L/usr/lib -lgdal -L/usr/local/lib -lgeos_c -L/usr/lib/R/lib -lR
installing to /home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/sf/libs
** R
** data
** demo
** inst
** byte-compile and prepare package for lazy loading
in method for ‘dbWriteTable’ with signature ‘"PostgreSQLConnection","character","sf"’: no definition for class “PostgreSQLConnection”
in method for ‘dbDataType’ with signature ‘"PostgreSQLConnection","sf"’: no definition for class “PostgreSQLConnection”
in method for ‘coerce’ with signature ‘"Spatial","sf"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"Spatial","sfc"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"sf","Spatial"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"sfc","Spatial"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"XY","Spatial"’: no definition for class “Spatial”
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/sf/libs/sf.so':
/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/sf/libs/sf.so: undefined symbol: GEOSFrechetDistanceDensify_r
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status
ERROR: dependency ‘sf’ is not available for package ‘lwgeom’
* removing ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/lwgeom’
Warning in install.packages :
installation of package ‘lwgeom’ had non-zero exit status
ERROR: dependency ‘sf’ is not available for package ‘mapview’
* removing ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/mapview’
Warning in install.packages :
installation of package ‘mapview’ had non-zero exit status
ERROR: dependency ‘sf’ is not available for package ‘stars’
* removing ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/stars’
Warning in install.packages :
installation of package ‘stars’ had non-zero exit status
ERROR: dependencies ‘sf’, ‘lwgeom’ are not available for package ‘tmaptools’
* removing ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/tmaptools’
Warning in install.packages :
installation of package ‘tmaptools’ had non-zero exit status
ERROR: dependencies ‘tmaptools’, ‘sf’, ‘mapview’ are not available for package ‘tmap’
* removing ‘/home/rodrigo/R/x86_64-pc-linux-gnu-library/3.5/tmap’
Warning in install.packages :
installation of package ‘tmap’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmptKPuTu/downloaded_packages’
What I don't understand (apart from the errors that I can't solve) is: how can sf be a dependency for lwgeom, and lwgeom be a dependency for sf at the same time?
Well, I ended up uninstalling and installing again both GDAL and GEOS, from Debian official repositories and from source, a few times. Until I got it right, don't know exactly how or why. In the end I got up with this:
ldconfig -v | grep gdal
libgdal.so.20 -> libgdal.so.20.1.2
ldconfig -v | grep geos
libgeos-3.7.1.so -> libgeos.so
libgeos_c.so.1 -> libgeos_c.so.1.11.1
libgeos-3.5.1.so -> libgeos-3.5.1.so
libgeos_c.so.1 -> libgeos_c.so.1.9.1
Which is quite similar to the first problem I had (more than one version of GEOS). So don't ask me...
The installation of lwgeom and sf gave a few warnings, but I was finally able to install spider.
EDIT
I've ran into the same problem again (trying to install stplanr). This time, I found out that I have installed one of libgeos' versions from source. So I went to the directory of the source and issued sudo make uninstall, which removed it nicely. Then I just reinstalled the official version from Debian repository, and now I could install both lwgeom and sf in R.

More problems installing rgdal on Ubuntu 16.04 - undefined symbol

I've been trying various suggestions on the many threads discussing how to install rgdal onto Ubuntu 16.04, and am still having trouble.
Here's where I've gotten to, after many false attempts. I tried the answer here (trouble in installing rgdal on ubuntu 16.04):
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal libgdal1-dev
This mostly worked, except that for libgdal1-dev, my package manager says the available version is 1.11.3, and that seemed to be giving me difficulties (not sure I can replicate at this stage), so I used Synaptic to uninstall that package and to install libgdal-dev instead, which had been flagged by Synaptic.
So at this point, according to Synaptic, when I do a search for "gdal", the installed files that show up are gdal-bin, gdal-data, libgdal-dev, libgdal20, python-gdal, and python3-gdal.
At this point, when I open R and run install.packages("rgdal"), this is what I get back:
Installing package into ‘/home/[username]/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rgdal_1.3-4.tar.gz'
Content type 'application/x-gzip' length 1664774 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /usr/lib/R
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... no
configure: svn revision: 766
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.2
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/share/gdal/2.2/pcs.csv readable... yes
configure: pkg-config proj exists, will use it
configure: PROJ version: 4.9.2
checking proj_api.h presence and usability... yes
checking PROJ version >= 4.8.0... yes
checking projects.h presence and usability... yes
checking PROJ.4: epsg found and readable... yes
checking PROJ.4: conus found and readable... yes
configure: Package CPP flags: -I/usr/include/gdal
configure: Package LIBS: -L/usr/lib -lgdal -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c OGR_write.cpp -o OGR_write.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal-bindings.cpp -o gdal-bindings.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c init.c -o init.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c inverser.c -o inverser.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c local_stubs.c -o local_stubs.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogr_geom.cpp -o ogr_geom.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogr_polygons.c -o ogr_polygons.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogr_proj.cpp -o ogr_proj.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogrdrivers.cpp -o ogrdrivers.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogrsource.cpp -o ogrsource.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c projectit.cpp -o projectit.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o rgdal.so OGR_write.o gdal-bindings.o init.o inverser.o local_stubs.o ogr_geom.o ogr_polygons.o ogr_proj.o ogrdrivers.o ogrsource.o projectit.o -L/usr/lib -lgdal -lproj -L/usr/lib/R/lib -lR
installing to /home/[username]/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** 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, ...):
unable to load shared object '/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs/rgdal.so':
/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs/rgdal.so: undefined symbol: _ZN10OGRFeature17GetFieldAsIntegerEi
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/rgdal’
The downloaded source packages are in
‘/tmp/Rtmpuc6qcT/downloaded_packages’
Warning message:
In install.packages("rgdal") :
installation of package ‘rgdal’ had non-zero exit status
I did a search for the error message, and found this question (Cannot install rgdal package in R on RHEL6, unable to load shared object rgdal.so), so tried running
ldconfig -c "echo '/usr/local/lib' >> /etc/ld.so.conf.d/R-dependencies-x86_64.conf"
but it doesn't seem to do anything and I'm still getting the same error message when I try to install rgdal.
Where do I go from here?
I'm on Ubuntu 18.04 but I just got the same problem (exact same error log) the solution for me was to link rgdal to a custom built of gdal. I was lucky enough that for other reason I already had a copy of GDAL (git master) built from source in /usr/local/gdal. So to install rgdal from source all i needed was to:
wget https://cran.r-project.org/src/contrib/rgdal_1.3-4.tar.gz
sudo R CMD INSTALL --configure-args=--with-gdal-config=/usr/local/gdal/bin/gdal-config rgdal_1.3-4.tar.gz
If you go this path, make sure your gdal installation has all the projection data installed in the expected location, mine wasn't so I had to add an extra step:
sudo cp -r /path/to/gdal-src-code/gdal/data/* /usr/local/gdal/share/gdal/

OpenMP support in R and RcppArmadillo

I struggle to enable OpenMP support for R in Ubuntu 16.04. When installing RcppArmadillo, OpenMP is 'found', but I get the following message when installing packages (e.g. 'forecast') that depend on RcppArmadillo:
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-
library/Rcpp/include" -I"/usr/local/lib/R/site-
library/RcppArmadillo/include" -fpic -g -O2 -fstack-protector-strong -
Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
calcBATS.cpp -o calcBATS.o
In file included from /usr/local/lib/R/site-
library/RcppArmadillo/include/armadillo:53:0,
from /usr/local/lib/R/site-
library/RcppArmadillo/include/RcppArmadilloForward.h:46,
from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:31,
from calcBATS.h:36,
from calcBATS.cpp:1:
/usr/local/lib/R/site-
library/RcppArmadillo/include/armadillo_bits/compiler_setup.hpp:474:96:
note: #pragma message: WARNING: use of OpenMP disabled; this compiler
doesn't support OpenMP 3.0+
#pragma message ("WARNING: use of OpenMP disabled; this compiler doesn't
support OpenMP 3.0+")
My ~/.R/Makevars are the following:
VER=-5.4
CC=ccache gcc-$(VER)
CXX=ccache g++-$(VER)
FC=ccache gfortran
F77=ccache gfortran
CXX11 =ccache g++-$(VER)
CXX14=ccache g++-$(VER)
CXX_STD = CXX11
CFLAGS= -O3 -Wall -pipe -pedantic -std=gnu11 -fopenmp
FCFLAGS=-O3 -Wall -pipe -pedantic -std=gnu11 -fopenmp
CXXFLAGS = -O3 -Wall -pipe -pedantic -std=gnu11 -fopenmp
CXX11FLAGS = -O3 -Wall -pipe -pedantic -std=gnu11 -fopenmp
CXX14FLAGS = -O3 -Wall -pipe -pedantic -std=gnu14 -fopenmp
PKG_CFLAGS= -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp
PKG_CXXFLAGS= -fopenmp
PKG_LIBS = -fopenmp -lgomp
CFLAGS= -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp
FCFLAGS=-O3 -g0 -Wall -pipe -fopenmp
I have played around with these settings, but nothing seems to help. Any wise thoughts would be appreciated. Many thanks.
Update:
I think some packages are using openMP now (e.g. xgboost). However, I still get the error message with some packages (e.g. Amelia):
* installing *source* package ‘Amelia’ ...
** package ‘Amelia’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-
library/Rcpp/include" -I"/usr/local/lib/R/site-
library/RcppArmadillo/include" -fpic -g -O2 -fstack-protector-strong -
Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
em.cpp -o em.o
In file included from /usr/local/lib/R/site-
library/RcppArmadillo/include/armadillo:53:0,
from /usr/local/lib/R/site-
library/RcppArmadillo/include/RcppArmadilloForward.h:46,
from /usr/local/lib/R/site-
library/RcppArmadillo/include/RcppArmadillo.h:31,
from em.h:3,
from em.cpp:2:
/usr/local/lib/R/site-
library/RcppArmadillo/include/armadillo_bits/compiler_setup.hpp:474:96:
note: #pragma message: WARNING: use of OpenMP disabled; this compiler
doesn't support OpenMP 3.0+
#pragma message ("WARNING: use of OpenMP disabled; this compiler doesn't
support OpenMP 3.0+")
^
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o
Amelia.so em.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -
lR
installing to /usr/local/lib/R/site-library/Amelia/libs
I can see that Amelia does not finish with '-fopenmp' unlike xgboost, but I don't know what else to add to my ~/.R/Makevars. Installation of xgboost ends in the following (note the -fopenmp):
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-
z,relro -o xgboost.so ./xgboost_R.o ./xgboost_custom.o ./xgboost_assert.o
./amalgamation/xgboost-all0.o ./amalgamation/dmlc-minimum0.o
./rabit/src/engine_empty.o ./rabit/src/c_api.o -fopenmp -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/xgboost/libs
The comment by #hejseb is correct. (Rcpp)Armadillo now wants to use OpenMP when it can---on new enough compilers.
But client packages need to turn this on, meaning they have to change their file src/Makevars from having just
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
to
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
to enable OpenMP in the client package on both compilation and linking.
And e.g. the forecast package does not yet do that.
You can also set "global" #define in your ~/.R/Makevars to skip OpenMP if you find this too noisy. But you'd leave some performance on the table, which is not a good default. Which is why (Rcpp)Armadillo makes the noisy comment.
Edit: There is one minor nuisance in that you need to set the flags for every C++ dialect so make sure you set CFLAGS, CXXFLAGS, CXX11FLAGS and CXX14FLAGS. You should see the -fopenmp on the command-line when R CMD INSTALL ... does its work.

e1071 install R 3.1.2

I am trying to install e1071 package in R 3.1.2. My system is linux 3.10.0-123.13.1.el7.x86_64. I tried to install from source with install.packages("e1071", type = "source"), but it did not help. Does anyone have suggestions?
* installing *source* package 'e1071' ...
** package 'e1071' successfully unpacked and MD5 sums checked
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
** libs
gcc -std=gnu99 -I/opt/local/stow/R-3.1.2/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c Rsvm.c -o Rsvm.o
gcc -std=gnu99 -I/opt/local/stow/R-3.1.2/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c cmeans.c -o cmeans.o
gcc -std=gnu99 -I/opt/local/stow/R-3.1.2/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c cshell.c -o cshell.o
gcc -std=gnu99 -I/opt/local/stow/R-3.1.2/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c floyd.c -o floyd.o
g++ -I/opt/local/stow/R-3.1.2/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c svm.cpp -o svm.o
In file included from /usr/include/stdio.h:934:0,
from /opt/local/stow/R-3.1.2/lib64/R/include/R.h:29,
from svm.cpp:1:
/usr/include/bits/stdio.h: In function '__ssize_t getline(char**, size_t*, FILE*)':
/usr/include/bits/stdio.h:117:52: error: '__getdelim' was not declared in this scope
make: *** [svm.o] Error 1
ERROR: compilation failed for package 'e1071'
Warning message:
In install.packages("e1071", dep = T) :
installation of package 'e1071' had non-zero exit status
Try
sudo yum install R-devel
or
sudo apt-get install R-devel
first

Resources