2

在构建我的包的过程中,我遇到了以下问题。我试图寻找解决方案但没有成功。为了使错误可重现,我提供了一个可以生成相同错误的最小包。

我启动了一个名为 mypkg 的包,然后使用usethis::use_rcppand usethis::use_rcpp_armadillo. 之后,我在 \src 文件夹中添加以下脚本(从互联网复制)

#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
arma::vec getEigenValues(arma::mat M) {
  return arma::eig_sym(M);
}

之后,我添加了一个 R shell 来使用 Roxygen 导出函数。到目前为止,该包可以成功记录和构建。然后我继续使用添加 Rstan 的功能rstantools::use_rstan,并按照Step by step guide 中的步骤创建依赖于 Rstan 的包,并按照说明创建 lm.stan 和 lm_stan.R。然后我再次构建了包,但它抛出了一个错误。下面是执行结果 .Last.error.trace

 1. devtools:::document()
 2. withr::with_envvar(r_env_vars(), roxygen2::roxygenise(pkg$path,  ...
 3. base:::force(code)
 4. roxygen2::roxygenise(pkg$path, roclets, load_code = load_code)
 5. roxygen2:::load_code(base_path)
 6. pkgload::load_all(path, helpers = FALSE, attach_testthat = FALSE)
 7. pkgbuild::compile_dll(path, quiet = quiet)
 8. pkgbuild:::install_min(path, dest = install_dir, components = "libs",  ...
 9. pkgbuild:::rcmd_build_tools("INSTALL", c(path, paste("--library=",  ...
 10. pkgbuild:::with_build_tools(callr::rcmd_safe(..., env = env,  ...
 11. withr::with_path(rtools_path(), code)
 12. base:::force(code)
 13. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE,  ...
 14. callr:::run_r(options)
 15. base:::with(options, with_envvar(env, do.call(processx::run,  ...
 16. base:::with.default(options, with_envvar(env, do.call(processx::run,  ...
 17. base:::eval(substitute(expr), data, enclos = parent.frame())
 18. base:::eval(substitute(expr), data, enclos = parent.frame())
 19. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs,  ...
 20. base:::force(code)
 21. base:::do.call(processx::run, c(list(bin, args = real_cmdargs,  ...
 22. (function (command = NULL, args = character(), error_on_status = TRUE,  ...
 23. throw(new_process_error(res, call = sys.call(), echo = echo,  ...
x System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
E> In file included from  C:/Users/Jasper/Documents/R/win-library/3.6/rstan/include/rstan/rstaninc.hpp:3:0,
E>                  from stanExports_lm.h:20,
E>                  from stanExports_lm.cc:5:
E> C:/Users/Jasper/Documents/R/win-library/3.6/rstan/include/rstan/stan_fit.hpp:11:28: fatal error: stan/version.hpp: No such file or directory 
E>  #include <stan/version.hpp> 
E>                            ^ 
E> compilation terminated.
E> make: *** [C:/PROGRA~1/R/R-36~1.2/etc/x64/Makeconf:213: stanExports_lm.o] Error 1 
E> ERROR: compilation failed for package 'mypkg' 
E> * removing 'C:/Users/Jasper/AppData/Local/Temp/RtmpwXHySZ/devtools_install_1d18454066b0/mypkg'

谁能提出问题是什么?这是我的makevars文件

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

但是,当我按照指南的步骤仅使用 Rstan 创建一个包时,它可以成功构建,但当我还想使用 RcppArmadillo 时则不行。

非常感谢您的热心帮助!!

4

0 回答 0