rdevtoolsopenair

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.


Solution

  • 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