1
votes

Here is the GitHub repo of my R package

I've been able to install this package from source on Windows, MacOS, and a Linux cluster with devtools::install_github("ntthung/ldsr")

I'm trying to integrate Travis CI and upon build, I get the following error

Error: package or namespace load failed for ‘ldsr’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/tmp/RtmpK7z3X6/Rinst2ef05609c709/00LOCK-ldsr/00new/ldsr/libs/ldsr.so':/tmp/RtmpK7z3X6/Rinst2ef05609c709/00LOCK-ldsr/00new/ldsr/libs/ldsr.so: undefined symbol: dpotrf_

I found that dpotrf_ belongs to a library called libflame. So I made the file Rload.R with te command Sys.setenv("PKG-LIBS"="-llibflame") and added the following to .travis.yml

script:
    - Rscript Rload.R
    - R CMD build . --compact-vignettes=gs+qpdf
    - R CMD check *tar.gz --as-cran

But I still get the same error.

My package uses Rcpp and RcppArmadillo.

Help please! Thanks.

1

1 Answers

5
votes

This looks like the basic error of not having a proper src/Makevars as would have been created from e.g. RcppArmadillo.package.skeleton() and others.

So as a first basic fix attempt, copy in the file inst/skeleton/Makevars from RcppArmadillo which contains

## With R 3.1.0 or later, you can uncomment the following line to tell R to 
## enable compilation with C++11 (where available)
##
## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider
## availability of the package we do not yet enforce this here.  It is however
## recommended for client packages to set it.
##
## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP
## support within Armadillo prefers / requires it
CXX_STD = CXX11

PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) 
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

You did copy in the Windows variant Makevars.win you just forgot the main one.

And dpotrf_ is a standard LAPACK symbol so the error is an obvious one for more experienced users (and this question is likely a duplicate too). Also, looking at the sources of the 600+ other CRAN packages using RcppArmadillo is often a good idea too -- they are all on GitHub under user cran.