在构建程序包的过程中,我遇到了以下问题。我试图寻找解决方案,但未成功。为了使该错误可再现,我提供了一个最小的程序包,它可以产生相同的错误。
我启动了一个名为mypkg的软件包,然后使用usethis::use_rcpp
和usethis::use_rcpp_armadillo
。之后,我将以下脚本添加到\ src文件夹(从Internet复制)中
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
arma::vec getEigenValues(arma::mat M) {
return arma::eig_sym(M);
}
在那之后,我添加了一个R shell以使用Roxygen导出函数。到目前为止,该软件包可以成功地记录和构建。
然后,我继续使用rstantools::use_rstan
添加Rstan的功能,并按照Step by step guide for creating a package that depends on 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时就不能成功。
非常感谢您的帮助!