首页 > 解决方案 > Travis CI 使用我的使用 C++、Rcpp 和 RcppArmadillo 的 R 包构建错误

问题描述

这是我的R 包的 GitHub 存储库

我已经能够在 Windows、MacOS 和 Linux 集群上从源代码安装这个包devtools::install_github("ntthung/ldsr")

我正在尝试集成 Travis CI,并在构建时收到以下错误

错误:dyn.load(文件,DLLpath = DLLpath,...)中“ldsr”的包或命名空间加载失败:无法加载共享对象“/tmp/RtmpK7z3X6/Rinst2ef05609c709/00LOCK-ldsr/00new/ldsr/libs/ ldsr.so':/tmp/RtmpK7z3X6/Rinst2ef05609c709/00LOCK-ldsr/00new/ldsr/libs/ldsr.so:未定义符号:dpotrf_

我发现它dpotrf_属于一个名为libflame. 所以我Rload.R用 te 命令制作了文件Sys.setenv("PKG-LIBS"="-llibflame")并将以下内容添加到.travis.yml

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

但我仍然得到同样的错误。

我的包使用 Rcpp 和 RcppArmadillo。

请帮忙!谢谢。

标签: rtravis-circpprcpparmadillo

解决方案


这看起来像是没有正确的基本错误,src/Makevars就像从eg RcppArmadillo.package.skeleton()和其他人创建的那样。

因此,作为第一次基本修复尝试,从 RcppArmadillo 复制文件inst/skeleton/Makevars,其中包含

## 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)

您确实复制了 Windows 变体Makevars.win,只是忘记了主要的变体。

并且dpotrf_是一个标准的 LAPACK 符号,因此对于更有经验的用户来说,这个错误是一个明显的错误(这个问题也可能是重复的)。此外,使用 RcppArmadillo 查看 600 多个其他 CRAN 包的来源通常也是一个好主意——它们都在 GitHub 上的 user 下cran


推荐阅读