通过 devtools 下载包(使用 RcppArmadillo)时出错

Error when downloading package (which uses RcppArmadillo) via devtools

我正在尝试使用 devtools 从 github 下载 R 包,但我 运行 遇到了一些问题。从我收到的错误消息来看,问题似乎与 RcppArmadillo 有关,因为 "dgemv_" 似乎是 RcppArmadillo 的一部分。卸载或重新安装 RcppArmadillo 不会停止错误。

由于收到此错误消息,我卸载了 R、RStudio 和 Rtools。我重新安装了 R,安装了一些包,安装了 Rtools,错误仍然存​​在。


在 R 中,我的会话信息是:

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppArmadillo_0.9.100.5.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.19      magrittr_1.5      usethis_1.4.0     devtools_2.0.0    pkgload_1.0.1     R6_2.3.0          rlang_0.3.0       tools_3.5.1      
 [9] pkgbuild_1.0.2    sessioninfo_1.1.0 cli_1.0.1         withr_2.1.2       remotes_2.0.1     assertthat_0.2.0  digest_0.6.18     rprojroot_1.3-2  
[17] crayon_1.3.4      processx_3.2.0    callr_3.0.0       base64enc_0.1-3   fs_1.2.6          ps_1.2.0          curl_3.2          memoise_1.1.0    
[25] glue_1.3.0        compiler_3.5.1    desc_1.2.0        backports_1.1.2   prettyunits_1.0.2

当我运行:

devtools::install_github("irinagain/mixedCCA")

我收到错误消息:

Downloading GitHub repo irinagain/mixedCCA@master
√  checking for file 'C:\Users\ben\AppData\Local\Temp\RtmpSQ7zwU\remotes2a5c2e561667\irinagain-mixedCCA-af59bb9/DESCRIPTION' (406ms)
-  preparing 'mixedCCA':
√  checking DESCRIPTION meta-information
-  cleaning src
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'mixedCCA_0.1.0.tar.gz'

* installing *source* package 'mixedCCA' ...
** libs

*** arch - i386
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-35~1.1/include" -DNDEBUG  -I"C:/Program Files/R/R-3.5.1/library/Rcpp/include" -I"C:/Program Files/R/R-3.5.1/library/RcppArmadillo/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-35~1.1/include" -DNDEBUG  -I"C:/Program Files/R/R-3.5.1/library/Rcpp/include" -I"C:/Program Files/R/R-3.5.1/library/RcppArmadillo/include"        -O2 -Wall  -mtune=generic -c find_w12.cpp -o find_w12.o
c:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o mixedCCA.dll tmp.def RcppExports.o find_w12.o -LC:/PROGRA~1/R/R-35~1.1/bin/i386 -lR
find_w12.o:find_w12.cpp:(.text$_ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE[__ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE]+0x361): undefined reference to `dgemv_'
find_w12.o:find_w12.cpp:(.text$_ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE[__ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE]+0x622): undefined reference to `dgemv_'
find_w12.o:find_w12.cpp:(.text$_ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE[__ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE]+0xa6b): undefined reference to `dgemv_'
find_w12.o:find_w12.cpp:(.text$_ZN4arma5ProxyINS_4GlueINS_3MatIdEENS_3ColIdEENS_10glue_timesEEEEC1ERKS7_[__ZN4arma5ProxyINS_4GlueINS_3MatIdEENS_3ColIdEENS_10glue_timesEEEEC1ERKS7_]+0x18c): undefined reference to `dgemv_'
find_w12.o:find_w12.cpp:(.text$_ZN4arma5ProxyINS_4GlueINS_3MatIdEENS_3ColIdEENS_10glue_timesEEEEC1ERKS7_[__ZN4arma5ProxyINS_4GlueINS_3MatIdEENS_3ColIdEENS_10glue_timesEEEEC1ERKS7_]+0x43a): undefined reference to `dgemv_'
find_w12.o:find_w12.cpp:(.text$_ZN4arma5ProxyINS_4GlueINS_3MatIdEENS_3ColIdEENS_10glue_timesEEEEC1ERKS7_[__ZN4arma5ProxyINS_4GlueINS_3MatIdEENS_3ColIdEENS_10glue_timesEEEEC1ERKS7_]+0x987): more undefined references to `dgemv_' follow
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'mixedCCA'
* removing 'C:/Program Files/R/R-3.5.1/library/mixedCCA'
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package ‘C:/Users/ben/AppData/Local/Temp/RtmpSQ7zwU/file2a5c4fb94283/mixedCCA_0.1.0.tar.gz’ had non-zero exit status

不是 Rcpp 问题,也不是 RcppArmadillo 问题,因为它显示

other attached packages:
[1] RcppArmadillo_0.9.100.5.0

RcppArmadillo 已通过 fone 加载。

我建议您在 mixedCCA 存储库中开票。

问题是在链接过程中没有提到 BLAS 和 LAPACK 库。为此,包作者应该使用类似

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

src/Makevars(.win)。当使用 RcppArmadillo::RcppArmadillo.package.skeleton() 设置包时,这会自动发生。但是,mixedCCA 根本没有 Makevars 文件:https://github.com/irinagain/mixedCCA/tree/master/src。你应该在 GH 上打开一个问题来解决这个问题。

我使用以下方法解决了这个问题:

  • 在本地克隆 repo
  • 创建一个文件 src/Makevars.win 包含以下行:PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
  • install.packages('path/to/the/repo', repos=NULL, type='source')