compilation failed for package ‘raster’ - r

I have problems to compile the "raster" package.
I tried
install.packages("raster", dependencies = TRUE)
with no success.
Any suggestions?
The main problem is:
g++ -m64 -std=gnu++0x -I/usr/include/R -DNDEBUG -I"/home/zfgbe/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c RasterModule.cpp -o RasterModule.o
In file included from RasterModule.cpp:2:
spat.h:158: error: ISO C++ forbids initialization of member ‘crs’
spat.h:158: error: making ‘crs’ static
spat.h:158: error: invalid in-class initialization of static data member of non-integral type ‘std::string’
spat.h: In member function ‘std::string SpRaster::getCRS()’:
spat.h:200: error: ‘crs’ was not declared in this scope
spat.h: In member function ‘void SpRaster::setCRS(std::string)’:
spat.h:201: error: ‘crs’ was not declared in this scope
make: *** [RasterModule.o] Error 1
ERROR: compilation failed for package ‘raster’

The problem is the depend on the rather new C++ Implementation (C++11).
The version 2.5-8 of raster does not have this dependency.
For me this installation command worked:
install.packages("https://cran.r-project.org/src/contrib/Archive/raster/raster_2.5-8.tar.gz", repos = NULL, type="source")

Related

Trouble installing packages in RStudio on Linux

I'm trying to install the following package in RStudio on Linux. I'm getting the follow error code. I don't really understand it. I was wondering if anyone could help me make sense of it.
Thanks,
Nick
> install.packages("PKI")
Installing package into ‘/home/nick/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/PKI_0.1-3.tar.gz'
Content type 'application/x-gzip' length 31058 bytes (30 KB)
==================================================
downloaded 30 KB
* installing *source* package ‘PKI’ ...
** package ‘PKI’ successfully unpacked and MD5 sums checked
** libs
gcc -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c asn1.c -o asn1.o
gcc -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c init.c -o init.o
gcc -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c pki-x509.c -o pki-x509.o
pki-x509.c: In function ‘PKI_extract_key’:
pki-x509.c:136:26: error: dereferencing pointer to incomplete type ‘EVP_PKEY {aka struct evp_pkey_st}’
if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA)
^~
pki-x509.c: In function ‘get_cipher’:
pki-x509.c:244:40: error: dereferencing pointer to incomplete type ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
ctx = (EVP_CIPHER_CTX*) malloc(sizeof(*ctx));
^~~~
pki-x509.c: In function ‘PKI_RSAkeygen’:
pki-x509.c:550:5: warning: ‘RSA_generate_key’ is deprecated [-Wdeprecated-declarations]
rsa = RSA_generate_key(bits, 65537, 0, 0);
^~~
In file included from /usr/include/openssl/rsa.h:13:0,
from pki.h:13,
from pki-x509.c:1:
/usr/include/openssl/rsa.h:193:1: note: declared here
DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void
^
make: *** [/usr/lib64/R/etc/Makeconf:159: pki-x509.o] Error 1
ERROR: compilation failed for package ‘PKI’
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/3.4/PKI’
Warning in install.packages :
installation of package ‘PKI’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpttDG6C/downloaded_packages’
I think I had the same problem recently.
I installed the package by downloading the most recent tarball (the .tar.gz file PKI_0.1-5.tar.gz) from the PKI RForge page and then running
install.packages(<tarball_path>, repos = NULL, type = "source").
EDIT: Actually, it's easier to run install.packages('PKI',,'http://www.rforge.net/') as written in small print at the bottom of the PKI RForge page
EDIT2: Looking at the news, it looks like version 0.1-4 (perhaps more stable) also fixes the problem and, well enough, it works on my system, while 0.1-3 doesn't (the one on CRAN currently).

R-3.1.3 installation from source errors .bss.zero_length_string' can not be used when making a shared object; recompile with -fPIC

I've been attempting to install R-3.1.3 from source on
# cat /etc/*release*
NAME="Amazon Linux AMI"
VERSION="2015.09"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2015.09"
PRETTY_NAME="Amazon Linux AMI 2015.09"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2015.09:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2015.09
cpe:/o:amazon:linux:2015.09:ga
And after ./configure && make installation fails with the following error
gcc -std=gnu99 -shared -fopenmp -L/usr/local/lib64 -o libRlapack.so
dlamch.o dlapack.o cmplx.o -L../../../lib -lRblas -lgfortran -lm -lquadmath
/usr/bin/ld: /usr/lib/gcc/x86_64-amazon-linux/4.8.3/libgfortran.a(string_intrinsics.o): relocation R_X86_64_32S against `.bss.zero_length_string' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-amazon-linux/4.8.3/libgfortran.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[4]: *** [libRlapack.so] Error 1
Naturally I learn about -fPIC on how to recompile with -fPIC and R_X86_64_32S on What do R_X86_64_32S and R_X86_64_64 relocation mean?
I then make the change in the CFLAGS
# ./configure 'CFLAGS=-g -O2 -fPIC' --with-x=no --enable-shared
I know it worked because configure prints the values it set,
C compiler: gcc -std=gnu99 -g -O2 -fPIC
Fortran 77 compiler: gfortran -g -O2
Nevertheless same error occurs.
I've tested this on Centos65, and Centos71 and Ubuntu1404 all work, but my VPC won't, please help

Can't install R package from source under CentOS

I am using CentOS
-bash-4.2$ cat /etc/*release*
CentOS Linux release 7.0.1406 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CentOS Linux release 7.0.1406 (Core)
CentOS Linux release 7.0.1406 (Core)
cpe:/o:centos:centos:7
to install purrr R package from source.
I am using R CMD INSTALL command to install this package but there appears and error that I do not understand and can't overcome. Does anyone know how to resolve this issue?
-bash-4.2$ R CMD INSTALL purrr_0.1.0.tar.gz
* installing to library
* installing *source* package ‘purrr’ ...
** pakiet ‘purrr’ został pomyślnie rozpakowany oraz sumy MD5 zostały sprawdzone
** libs
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -I/usr/local/include -I"/usr/lib64/R/library/Rcpp/include" -I"/usr/lib64/R/library/dplyr/include" -I"/usr/lib64/R/library/BH/include" -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c RcppExports.cpp -o RcppExports.o
In file included from /usr/lib64/R/library/BH/include/boost/tuple/tuple.hpp:33:0,
from /usr/lib64/R/library/BH/include/boost/unordered/detail/allocate.hpp:27,
from /usr/lib64/R/library/BH/include/boost/unordered/detail/buckets.hpp:15,
from /usr/lib64/R/library/BH/include/boost/unordered/detail/table.hpp:10,
from /usr/lib64/R/library/BH/include/boost/unordered/detail/equivalent.hpp:14,
from /usr/lib64/R/library/BH/include/boost/unordered/unordered_map.hpp:17,
from /usr/lib64/R/library/BH/include/boost/unordered_map.hpp:16,
from /usr/lib64/R/library/dplyr/include/dplyr.h:32,
from RcppExports.cpp:4:
/usr/lib64/R/library/BH/include/boost/tuple/detail/tuple_basic.hpp: In function ‘typename boost::tuples::access_traits<typename boost::tuples::element<N, boost::tuples::cons<HT, TT> >::type>::const_type boost::tuples::get(const boost::tuples::cons<HT, TT>&)’:
/usr/lib64/R/library/BH/include/boost/tuple/detail/tuple_basic.hpp:228:45: warning: typedef ‘cons_element’ locally defined but not used [-Wunused-local-typedefs]
typedef BOOST_DEDUCED_TYPENAME impl::type cons_element;
^
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -I/usr/local/include -I"/usr/lib64/R/library/Rcpp/include" -I"/usr/lib64/R/library/dplyr/include" -I"/usr/lib64/R/library/BH/include" -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c fast-copy.cpp -o fast-copy.o
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -I/usr/local/include -I"/usr/lib64/R/library/Rcpp/include" -I"/usr/lib64/R/library/dplyr/include" -I"/usr/lib64/R/library/BH/include" -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c rows.cpp -o rows.o
In file included from /usr/lib64/R/library/BH/include/boost/tuple/tuple.hpp:33:0,
from /usr/lib64/R/library/BH/include/boost/unordered/detail/allocate.hpp:27,
from /usr/lib64/R/library/BH/include/boost/unordered/detail/buckets.hpp:15,
from /usr/lib64/R/library/BH/include/boost/unordered/detail/table.hpp:10,
from /usr/lib64/R/library/BH/include/boost/unordered/detail/equivalent.hpp:14,
from /usr/lib64/R/library/BH/include/boost/unordered/unordered_map.hpp:17,
from /usr/lib64/R/library/BH/include/boost/unordered_map.hpp:16,
from /usr/lib64/R/library/dplyr/include/dplyr.h:32,
from rows.cpp:2:
/usr/lib64/R/library/BH/include/boost/tuple/detail/tuple_basic.hpp: In function ‘typename boost::tuples::access_traits<typename boost::tuples::element<N, boost::tuples::cons<HT, TT> >::type>::const_type boost::tuples::get(const boost::tuples::cons<HT, TT>&)’:
/usr/lib64/R/library/BH/include/boost/tuple/detail/tuple_basic.hpp:228:45: warning: typedef ‘cons_element’ locally defined but not used [-Wunused-local-typedefs]
typedef BOOST_DEDUCED_TYPENAME impl::type cons_element;
^
rows.cpp: In function ‘SEXPREC* subset_slices(const List&)’:
rows.cpp:18:3: error: ‘DataFrameSubsetVisitors’ is not a member of ‘dplyr’
dplyr::DataFrameSubsetVisitors visitors(data);
^
rows.cpp:18:34: error: expected ‘;’ before ‘visitors’
dplyr::DataFrameSubsetVisitors visitors(data);
^
rows.cpp:22:14: error: ‘visitors’ was not declared in this scope
out[i] = visitors.subset(indices[i], classes);
^
rows.cpp: In function ‘SEXPREC* by_row_impl(const List&, SEXP, SEXP, int, const Environment&)’:
rows.cpp:232:3: error: ‘DataFrameSubsetVisitors’ is not a member of ‘dplyr’
dplyr::DataFrameSubsetVisitors visitors(data);
^
rows.cpp:232:34: error: expected ‘;’ before ‘visitors’
dplyr::DataFrameSubsetVisitors visitors(data);
^
rows.cpp:237:16: error: ‘visitors’ was not declared in this scope
SEXP row = visitors.subset(IntegerVector::create(i), classes);
^
make: *** [rows.o] Błąd 1
ERROR: compilation failed for package ‘purrr’
The solution looks to be trivial https://github.com/hadley/purrr/issues/146
I had an old version of a dependent dplyr package.

RGL package for R compile error

Attempting to compile rgl for r on arch linux x86_64. I copied just the error portion of the installation. This has occurred after I recently updated R. Any idea how to solve this?
g++ -I/usr/include/R/ -DNDEBUG -DHAVE_PNG_H -I/usr/include/libpng16 -DHAVE_FREETYPE -Iext/ftgl -I/usr/include/freetype2 -Iext -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fvisibility=hidden -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -c init.cpp -o init.o
In file included from /usr/include/freetype2/freetype.h:33:0,
from ext/ftgl/FTGL/ftgl.h:33,
from glgui.h:12,
from gui.h:10,
from rglview.h:11,
from Device.h:11,
from DeviceManager.h:9,
from init.cpp:6:
init.cpp: In function ‘SEXPREC* rgl::rgl_init(SEXP, SEXP, SEXP)’:
/usr/include/freetype2/config/ftconfig.h:369:26: error: expected primary-expression before ‘__typeof__’
#define TYPEOF( type ) (__typeof__ (type))
^
init.cpp:58:13: note: in expansion of macro ‘TYPEOF’
else if ( TYPEOF(initValue) == EXTPTRSXP ) {
^
/usr/include/freetype2/config/ftconfig.h:369:26: error: expected ‘)’ before ‘__typeof__’
#define TYPEOF( type ) (__typeof__ (type))
^
init.cpp:58:13: note: in expansion of macro ‘TYPEOF’
else if ( TYPEOF(initValue) == EXTPTRSXP ) {
^
init.cpp:61:3: error: expected ‘)’ before ‘else’
else if ( !isNull(initValue) )
^
/usr/lib64/R/etc/Makeconf:143: recipe for target 'init.o' failed
make: *** [init.o] Error 1
ERROR: compilation failed for package ‘rgl’
* removing ‘/home/user/R/x86_64-unknown-linux-gnu-library/3.2/rgl’
Warning in install.packages :
installation of package ‘rgl’ had non-zero exit status
Freetype is optional. Disabling it is the least hassles solution.
install.packages("rgl", repo="http://cran.r-project.org", configure.args="--disable-ftgl")
The issue is with freetype2 2.6. Downgrading to freetype2 2.5 allows rgl to compile properly.
For archlinux you can just run pacman -U /var/cache/pacman/pkg/freetype2-2.5.5-1-x86_64.pkg.tar.xz to downgrade to the older package.
For others who come looking I solved this on ubuntu by installing libfreetype6-dev
Get the binary from the repos:
sudo apt-get build-dep r-cran-rgl
or
Install OpenGL before building rgl from source.

github_install & R CMD INSTALL fails for videoplayR

I was trying to install the package videoplayR from github but failed to do the same. I tried two ways:
1. Using the installation guidance mentioned in README file.It gave the following error:
> install_github("sjmgarnier/videoplayR")
Downloading github repo sjmgarnier/videoplayR#master
Error in function (type, msg, asError = TRUE) :
2. Using R CMD SHLIB etc gives the following error while running R CMD check. It is a part of the install.out file:
* installing source package ‘videoplayR’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/home/nandy/R/x86_64-pc-linux-gnu-library/3.1/Rcpp/include" -I"/home/nandy/R/x86_64-pc-linux-gnu-library/3.1/RcppArmadillo/include" pkg-config --cflags opencv Rscript -e <p>'Rcpp:::CxxFlags()' -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -I/usr/share/R/include -DNDEBUG -I"/home/nandy/R/x86_64-pc-linux-gnu-library/3.1/Rcpp/include" -I"/home/nandy/R/x86_64-pc-linux-gnu-library/3.1/RcppArmadillo/include" pkg-config --cflags opencv Rscript -e <p>'Rcpp:::CxxFlags()' -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c Video.cpp -o Video.o
Video.cpp: In member function ‘double Video::current_frame()’:
Video.cpp:42:25: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
return(inputVideo.get(CV_CAP_PROP_POS_FRAMES));
^
Video.cpp: In member function ‘void Video::set_current_frame(int)’:
Video.cpp:46:18: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
inputVideo.set(CV_CAP_PROP_POS_FRAMES, n);
^
Video.cpp: In member function ‘void Video::next_frame_cv()’:
Video.cpp:63:22: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
if (inputVideo.get(CV_CAP_PROP_POS_FRAMES) == inputVideo.get(CV_CAP_PROP_FRAME_COUNT)) {
^
Video.cpp:63:64: error: ‘CV_CAP_PROP_FRAME_COUNT’ was not declared in this scope
if (inputVideo.get(CV_CAP_PROP_POS_FRAMES) == inputVideo.get(CV_CAP_PROP_FRAME_COUNT)) {
^
Video.cpp: In member function ‘void Video::get_frame_cv(int)’:
Video.cpp:76:27: error: ‘CV_CAP_PROP_FRAME_COUNT’ was not declared in this scope
if (n > inputVideo.get(CV_CAP_PROP_FRAME_COUNT)) {
^
Video.cpp:80:18: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
inputVideo.set(CV_CAP_PROP_POS_FRAMES, n);
^
Video.cpp: In member function ‘int Video::length()’:
Video.cpp:91:25: error: ‘CV_CAP_PROP_FRAME_COUNT’ was not declared in this scope
return(inputVideo.get(CV_CAP_PROP_FRAME_COUNT));
^
I am guessing problem 2 is occurring due to version problem of OpenCV. Am I right? Is there any way out of this?
Looks similar to these 2 reported problems: https://github.com/hadley/devtools/issues/650 and https://github.com/hadley/devtools/issues/467. It seems that you need to update your system (Linux I presume) to the latest version of Curl.
I believe this is my fault. I forgot to exclude the compiled shared object videoplayR.so last time I committed changes to the GitHub repo. If you're using a different OS than mine (OSX Yosemite), it is most certainly the cause of the problem that you encountered. I fixed it and now it should compile nicely on your computer as well.
FYI I compiled and ran the package with both OpenCV 2.4.9 and 2.4.10, but it should work with any 2.4.X version of OpenCV (never tried the latest OpenCV 3.0 beta).

Resources