Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - cannot find -llapack & cannot find -lblas

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.

like image 835
Run Avatar asked Sep 02 '19 21:09

Run


People also ask

Why can't R find my function?

This error usually occurs when a package has not been loaded into R via library . R does not know where to find the specified function. It's a good habit to use the library functions on all of the packages you will be using in the top R chunk in your R Markdown file, which is usually given the chunk name setup .

Where is my R folder?

R packages are a collection of R functions, complied code and sample data. They are stored under a directory called "library" in the R environment. By default, R installs a set of packages during installation.

How do I manually install an R package?

Go into R, click on Packages (at the top of the R console), then click on "Install package(s) from local zip files", then find the zip file with arm from wherever you just saved it. Do the same thing to install each of the other packages you want to install.


2 Answers

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
like image 83
r2evans Avatar answered Oct 30 '22 16:10

r2evans


@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 <[email protected]>                                                                                          
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:~$
like image 38
Dirk Eddelbuettel Avatar answered Oct 30 '22 17:10

Dirk Eddelbuettel