I am using R in Ubuntu 10.04.
I need to understand the documentation.
Installing knncat I get this error message:
gcc -I/usr/share/R/include -I . -DUSE_R_ALLOC -DCALL_FROM_R -fpic
-std=gnu99 -O3 -pipe -g -c ranlib.c -o ranlib.o gcc -I/usr/share/R/include -I . -DUSE_R_ALLOC -DCALL_FROM_R -fpic -std=gnu99 -O3 -pipe -g -c utilsR.c -o utilsR.o gcc -shared -o knncat.so com.o dodisc.o donn.o donnwrap.o dsort.o linpack.o matrix.o
objective.o ords.o ranlib.o utilsR.o -llapack -lblas -lgfortran -lm
-L/usr/lib/R/lib -lR /usr/bin/ld: cannot find -llapack collect2: ld returned 1 exit status make: *** [knncat.so] Error 1 ERROR:
compilation failed for package ‘knncat’
In the documentation I find this recomendation:
Provision is made for using an external LAPACK library, principally to
cope with BLAS libraries which contain a copy of LAPACK (such as sunperf
on Solaris, vecLib on OS X and ACML on ‘ix86’/‘x86_64’ Linux)
If it is mandatory (?), I should use this code:
--with-lapack="-L/path/to/libs -llapack -lcblas"
But where? I am using the standard installation of packages in R.
install.packages('knncat')
I am not sure of:
Is it mandatory to install lapack? I do have BLAS + LAPACK.
How to install a package without using install.packages()?
which are the choices I have now?
Please install the r-base-dev package, which will take care of the -dev packages for LAPACK and BLAS as well.
It was an old version of R. Even when I did upgrade, it does not fixed.
I followed this orders: from http://ubuntuforums.org/showthread.php?t=377323
sudo aptitude install r-base r-recommended
In R
install.packages('knncat')
Now it is working!
Related
I try to install R packages by using devtools (for specific version) but got some errors.
I have to install packages that's specific version and use specific R version (4.1.*) plz.
R, devtools version
R version : 4.1.3
devtools: 2.4.4
Install packages
forecast : 8.13
kernlab : 0.9-29
Install commands
install_version("forecast", version = "8.13")
install_version("kernlab", version = "0.9-29")
or add option dependencies=TRUE
Error list
cc -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 -fdebug-prefix-ma
p=/build/r-base-NlA7dw/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-s
ecurity -Wdate-time -D_FORTIFY_SOURCE=2 -g -c registerDynamicSymbol.c -o registerDynami
cSymbol.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I'/usr/local/lib/R/site-library/Rcp
p/include' -I'/usr/local/lib/R/site-library/RcppArmadillo/include' -fpic -g -O2 -fde
bug-prefix-map=/build/r-base-NlA7dw/r-base-4.1.3=. -fstack-protector-strong -Wformat -We
rror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c updateMatrices.cpp -o update
Matrices.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I'/usr/local/lib/R/site-library/Rcp
p/include' -I'/usr/local/lib/R/site-library/RcppArmadillo/include' -fpic -g -O2 -fde
bug-prefix-map=/build/r-base-NlA7dw/r-base-4.1.3=. -fstack-protector-strong -Wformat -We
rror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c updateTBATSMatrices.cpp -o u
pdateTBATSMatrices.o
g++ -std=gnu++14 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o forec
ast.so calcBATS.o calcTBATS.o etsTargetFunction.o etsTargetFunctionWrapper.o etscalc.o e
tspolyroot.o makeBATSMatrices.o makeTBATSMatrices.o registerDynamicSymbol.o updateMatric
es.o updateTBATSMatrices.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -l
R
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:10: recipe for target 'forecast.so' failed
make: *** [forecast.so] Error 1
ERROR: compilation failed for package ‘forecast’
* removing ‘/usr/local/lib/R/site-library/forecast’
경고메시지(들):
i.p(...)에서:
installation of package ‘/tmp/RtmpGgApec/remotes25555374bfb7/forecast’ had non-zero ex
it status
Commands I've tried
sudo apt-get install g++
sudo apt install gfortran
sudo apt install libcurl4-gnutls-dev
R version upgrade 4.1.0 -> 4.1.3
R version downgrade 4.1.3 -> 4.1.0
install.packages('forecast')
install.packages('kernlab')
Short answer: We supply a package with the most common dependencies so consider doing sudo apt-get install r-base-dev. After that you can compile.
Longer answer: Ubuntu contains a number of pre-built CRAN packages. Consider doing sudo apt install r-cran-kernlab r-cran-forecast. For an older Ubuntu release this may reflect older versions.
Best answer (if you are on Ubuntu 20.04 or 22.04): Consider r2u which has all (!!) of the CRAN packages as r-cran-binaries, and uses bspm so that you can just say install.packages(c("kernlab", "forecast")) and still get everything pre-made as binaries, with dependencies, and managed via apt. But we do not support 18.04 for that.
In general when libraries are missing, "cannot find -lXXX", you should apt-cache search libXXX + -dev, and apt-get install what you find.
So in this case:
sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev
A related answer.
I can't install openair for some reasons:
sudo su - -c "R -e \"devtools::install_github('davidcarslaw/openair')\""
Result:
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘openair’ ...
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/build/r-base-V0XiTa/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c cluster.cpp -o cluster.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/build/r-base-V0XiTa/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c init.c -o init.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fdebug-prefix-map=/build/r-base-V0XiTa/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c rolling.cpp -o rolling.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o openair.so cluster.o init.o rolling.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: openair.so] Error 1
ERROR: compilation failed for package ‘openair’
* removing ‘/usr/local/lib/R/site-library/openair’
Error: Failed to install 'openair' from GitHub:
(converted from warning) installation of package ‘/tmp/Rtmp36VYYZ/file18ef44881cd2/openair_2.6-5.tar.gz’ had non-zero exit status
Execution halted
What am I missing?
I am on Ubuntu 19.04.
Many R packages need underlying DLLs (shared objects) that are specific for compiling against, and they often have a -dev suffix on the package name. On my 16.04 Ubuntu system, I see:
$ apt list --installed | egrep 'lapack|blas'
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libblas-common/xenial,now 3.6.0-2ubuntu2 amd64 [installed,automatic]
libblas-dev/xenial,now 3.6.0-2ubuntu2 amd64 [installed,automatic]
libblas3/xenial,now 3.6.0-2ubuntu2 amd64 [installed,automatic]
liblapack-dev/xenial,now 3.6.0-2ubuntu2 amd64 [installed,automatic]
liblapack3/xenial,now 3.6.0-2ubuntu2 amd64 [installed,automatic]
(I also often cheat and look at:
$ ll /var/lib/dpkg/info/*lapack*.list
-rw-r--r-- 1 root root 318 Apr 27 2017 /var/lib/dpkg/info/liblapack3.list
-rw-r--r-- 1 root root 288 Apr 27 2017 /var/lib/dpkg/info/liblapack-dev.list
and while not fast or as flexible a way of looking, it quickly lets me look at the file-listings (these files) or the pre/post-install scripts, if present. Just a hack.)
If you don't have the two -dev packages, you can installed either or both with:
apt-get install libblas-dev liblapack-dev
#r2evans gave the correct answer in the general case.
For R on Debian and Ubuntu, there is short cut worth knowing about: And that short cut is, and has been for close to 20 years, that you want the r-base-dev package installed as it will bring in a number of build requirements.
Such as these lapack and blas -dev libraries.
edd#rob:~$ apt-cache show r-base-dev
Package: r-base-dev
Architecture: all
Version: 3.6.1-3disco
Priority: optional
Section: gnu-r
Source: r-base
Maintainer: Dirk Eddelbuettel <edd#debian.org>
Installed-Size: 15
Depends: r-base-core (>= 3.6.1-3disco), build-essential, gcc, g++, gfortran, libblas-dev | libatlas-base-dev, liblapack-dev | libatlas-base-dev, libncurses5-dev, libreadline-dev, libjpeg-dev, libpcre2-dev, libpc
re3-dev, libpng-dev, zlib1g-dev, libbz2-dev, liblzma-dev, libicu-dev, xauth, pkg-config
Suggests: texlive-base, texlive-latex-base, texlive-plain-generic, texlive-fonts-recommended, texlive-fonts-extra, texlive-extra-utils, texlive-latex-recommended, texlive-latex-extra, texinfo
Filename: disco-cran35/r-base-dev_3.6.1-3disco_all.deb
Size: 4488
MD5sum: 9eb92e1184dc4b959cc493ba3fdb4c22
SHA1: e7804d6bbd90eb8ed4e2d42340abbc45fd7192a3
SHA256: 18509fb6a684d011fe983384b92ba7b2b72717de7e6169007c43a4a875fcbc03
SHA512: 4ea302cddad643ede8ec9719f496b5e74569c39325b86ecebd39d9610e668ed6e0d8619e07341c91a196708f2172a9f594fb6a317e2eb386c928d5e9ed4111f5
Homepage: http://www.r-project.org/
Description-en: GNU R installation of auxiliary GNU R packages
R is a system for statistical computation and graphics. It consists
of a language plus a run-time environment with graphics, a debugger,
access to certain system functions, and the ability to run programs
stored in script files.
.
The design of R has been heavily influenced by two existing languages:
Becker, Chambers & Wilks' S and Sussman's Scheme. Whereas the
resulting language is very similar in appearance to S, the underlying
implementation and semantics are derived from Scheme.
.
.
The core of R is an interpreted computer language which allows
branching and looping as well as modular programming using functions.
Most of the user-visible functions in R are written in R. It is
possible for the user to interface to procedures written in the
C, C++, or FORTRAN languages for efficiency, and many of R's core
functions do so. The R distribution contains functionality for a
large number of statistical procedures and underlying applied math
computations. There is also a large set of functions which provide
a flexible graphical environment for creating various kinds of data
presentations.
.
Additionally, several thousand extension "packages" are available from
CRAN, the Comprehensive R Archive Network, many also as Debian packages,
named 'r-cran-<name>'.
.
This package ensures that other Debian packages needed for installation of
some auxiliary R packages are installed.
Description-md5: 1a1267651faee382ef4781870ce94812
edd#rob:~$
I'm trying to install fst R package from CRAN but I get error:
gcc -I"/path/apps/R/3.5.1-20180807-test/x86_64-linux-2.6-rhel6/lib64/R/include" -DNDEBUG
-fopenmp -I. -Ifstcore -Ifstcore_v1 -Ifstcore/LZ4 -Ifstcore/ZSTD -Ifstcore/ZSTD/common
-Ifstcore/ZSTD/decompress -Ifstcore/ZSTD/compress
-I"/path/apps/R/3.5.1-20180807-test/x86_64-linux-2.6-rhel6/r_libs_site/Rcpp/include"
-I /path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/include -fpic
-I /path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/include
-c fstcore/ZSTD/compress/huf_compress.c -o fstcore/ZSTD/compress/huf_compress.o
gcc -I"/path/apps/R/3.5.1-20180807-test/x86_64-linux-2.6-rhel6/lib64/R/include" -DNDEBUG
-fopenmp -I. -Ifstcore -Ifstcore_v1 -Ifstcore/LZ4 -Ifstcore/ZSTD -Ifstcore/ZSTD/common
-Ifstcore/ZSTD/decompress -Ifstcore/ZSTD/compress
-I"/path/apps/R/3.5.1-20180807-test/x86_64-linux-2.6-rhel6/r_libs_site/Rcpp/include"
-I /path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/include -fpic
-I /path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/include
-c fstcore/ZSTD/decompress/zstd_decompress.c -o fstcore/ZSTD/decompress/zstd_decompress.o
/tmp/cc0LoSFX.s: Assembler messages:
/tmp/cc0LoSFX.s:7353: Error: no such instruction: `shlx %rax,%rdx,%rax'
/tmp/cc0LoSFX.s:8204: Error: no such instruction: `shlx %rax,%rdx,%rax'
/tmp/cc0LoSFX.s:8608: Error: no such instruction: `shlx %rax,%rdx,%rax'
make: *** [fstcore/ZSTD/decompress/zstd_decompress.o] Error 1
ERROR: compilation failed for package ‘fst’
I there any required linux library that can be compiled from source? What else I can do?
EDIT:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/path/apps/gcc/6.3.0/x86_64-linux-2.6-rhel6/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/path/apps/gcc/6.3.0/x86_64-linux-2.6-rhel6 --disable-multilib
Thread model: posix
gcc version 6.3.0 (GCC)
Putting this here for posterity in case others eventually land on this question when facing similar issues.
It turns out that as far as we can tell, the problem was incompatible versions of the assembler (/usr/bin/as) and gcc (our non-system 6.3.0 installation).
So if you landed here at the end of your rope with no idea why you're seeing these errors, looking into getting a compatible version of the assembler (in linux world this is part of the binutils module/project). Hope that helps.
I am very new to R language. Being an admin I am setting up an rserver and installing the required packages for my use of this R server with SAP HANA 1.0.
The fundamental problem here is when i am installing the rcpp.0.12.16 and getting the below error. g++ is 4.8-6.189.
Are there an incompatibilities witht the OS version R version and rccp package i am using? Please help resolving this issue.
> setwd("/Media/R/R_indep_pack")
> install.packages("Rcpp_0.12.16.tar.gz",repos = NULL, type="source")
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c Date.cpp -o Date.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c Module.cpp -o Module.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c Rcpp_init.cpp -o Rcpp_init.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c api.cpp -o api.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c attributes.cpp -o attributes.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c barrier.cpp -o barrier.o
g++ -L/usr/local/lib64/R/lib -L/usr/local/lib64 -o Rcpp.so Date.o Module.o
Rcpp_init.o api.o attributes.o barrier.o -L/usr/local/lib64/R/lib -lR
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o: In function
`_start':
/home/abuild/rpmbuild/BUILD/glibc-2.22/csu/../sysdeps/x86_64/start.S:114:
undefined reference to `main'
collect2: error: ld returned 1 exit status
/usr/local/lib64/R/share/make/shlib.mk:6: recipe for target 'Rcpp.so' failed
make: *** [Rcpp.so] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/usr/local/lib64/R/library/Rcpp’
Warning message:
In install.packages("Rcpp_0.12.16.tar.gz", repos = NULL, type = "source") :
installation of package ‘Rcpp_0.12.16.tar.gz’ had non-zero exit status
>
Your linker is looking for a main function since it is not told to build a shared library:
g++ -L/usr/local/lib64/R/lib -L/usr/local/lib64 -o Rcpp.so Date.o Module.o
Rcpp_init.o api.o attributes.o barrier.o -L/usr/local/lib64/R/lib -lR
Here a -shared is missing from the command line. The command line flags used here are defined via the Makevars file:
$ grep SHLIB.*LDFLAGS $(R RHOME)/etc/Makeconf
SHLIB_CXXLDFLAGS = -shared
SHLIB_CXX98LDFLAGS = -shared
SHLIB_CXX11LDFLAGS = -shared
SHLIB_CXX14LDFLAGS = -shared
SHLIB_CXX17LDFLAGS = -shared
SHLIB_FCLDFLAGS = -shared
SHLIB_LDFLAGS = -shared# $(CFLAGS) $(CPICFLAGS)
SHLIB_LINK = $(SHLIB_LD) $(SHLIB_LDFLAGS) $(LIBR0) $(LDFLAGS)
SHLIB_CXX1XLDFLAGS = -shared
Either these are incorrectly set on your system or you are overriding them via ~/.R/Makevars.
In ubuntu, in such situation, I would search for
apt search rcpp # search in central repository for \
# packages for R packages
In this case, this leads to 'r-cran-rcpp' package which I then install with
sudo apt install r-cran-rcpp
(such packages from 'r-cran-' help, because they install for you the further dependencies in the system - which are often dependencies outside of R - automatically for you. E.g. some packages require java or some other system libraries.).
Similarly, you have to search in rpm or yast2 repos for rcpp packages.
I found googling http://rpmfind.net/linux/rpm2html/search.php?query=R-Rcpp
or http://rpm.pbone.net/index.php3/stat/4/idpl/33595438/dir/opensuse/com/R-RcppArmadillo-0.4.450.1.0-2.38.i586.rpm.html
Or: if you are using conda:
conda install -c r r-rcpp
would definitely help ...
If you don't know conda: This tutorial is super!
https://www.youtube.com/watch?v=YJC6ldI3hWk
Just spend 11 minutes and you will be able to use conda!
(With conda, you can install several R versions with all their packages in parallel in your system - sometimes you need that because some versions are not compativle with some R packages - conda creates for you different local environments within which you can install programs with all their specific dependencies. And you can switch between the environments.)
I definitely recommend you to use conda. Because this solves many package dependency problems.
I am trying to install R’s plyr package. Here is the error message:
* installing *source* package ‘plyr’ ...
** package ‘plyr’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/opt/R-3.4.1/include -DNDEBUG -I"/home/isomorphismes/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -I/opt/boost_1_61_0/boost -c RcppExports.cpp -o RcppExports.o
clang -I/opt/R-3.4.1/include -DNDEBUG -I"/home/cd/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -g -O2 -flto -c loop_apply.c -o loop_apply.o
clang++ -I/opt/R-3.4.1/include -DNDEBUG -I"/home/isomorphismes/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -I/opt/boost_1_61_0/boost -c split-numeric.cpp -o split-numeric.o
clang++ -shared -L/usr/local/lib -o plyr.so RcppExports.o loop_apply.o split-numeric.o
loop_apply.o: file not recognized: File format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/opt/R-3.4.1/share/make/shlib.mk:6: recipe for target 'plyr.so' failed
make: *** [plyr.so] Error 1
ERROR: compilation failed for package ‘plyr’
* removing ‘/home/cd/R/i686-pc-linux-gnu-library/3.4/plyr’
The *.o files are in /opt/plyr/src, from github.com/hadley/plyr. They look like this on my system:
i#scheherezade:/opt/plyr/src$ file *o
loop_apply.o: LLVM IR bitcode
RcppExports.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
split-numeric.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
In case you didn't know, -flto specifies link time optimization, and has been added by R. How did you manage to end up with such a mis-configured R install?
Adding -flto to the link command may work? Or remove it from the loop_apply compilation line. If either of those works, you need to fix your R install.
Compiling with -flto using clang requires (on Ubuntu) installing the llvm-dev package. Otherwise, the linker is unable to handle -flto object files.
apt-get install clang-10 llvm-10-dev
Now the linking should succeed.