问题描述
我正在尝试在 RcppArmadillo 中使用 spsolve 函数。
根据 this 帖子,我编译了以下 test.cpp
代码(与该帖子的示例相同)。
// Important: this definition ensures Armadillo enables SuperLU
#define ARMA_USE_SUPERLU 1
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace arma;
// [[Rcpp::export]]
void superLuDemo() {
sp_mat A = sprandu<sp_mat>(1000,1000,0.1);
vec b = randu<vec>(1000);
mat B = randu<mat>(1000,5);
vec x = spsolve(A,b); // solve one system
mat X = spsolve(A,B); // solve several systems
bool status = spsolve(x,A,b); // use default solver
if (status == false) { Rcpp::Rcout << "no solution" << endl; }
spsolve(x,b,"lapack"); // use LAPACK solver
spsolve(x,"superlu"); // use SuperLU solver
Rcpp::Rcout << "Done.\n";
}
但是我得到编译错误。
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-41~1.0/include" -DNDEBUG -I../inst/include -fopenmp -I"C:/Users/mirai/Documents/R/win-library/4.1/Rcpp/include" -I"C:/Users/mirai/Documents/R/win-library/4.1/RcppArmadillo/include" -I"C:/Users/mirai/Dropbox/Rfiles/Pinterest_research/empirical_analysis3" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c test.cpp -o test.o
C:/rtools40/mingw64/bin/g++ -shared -s -static-libgcc -o sourceCpp_4.dll tmp.def test.o -fopenmp -LC:/PROGRA~1/R/R-41~1.0/bin/x64 -lRlapack -LC:/PROGRA~1/R/R-41~1.0/bin/x64 -lRblas -lgfortran -lm -lquadmath -lsuperlu -LC:/PROGRA~1/R/R-41~1.0/bin/x64 -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsuperlu
collect2.exe: error: ld returned 1 exit status
Error in Rcpp::sourceCpp("empirical_analysis3/test.cpp") :
Error occurred building shared library.
你有什么想法吗?非常感谢。
环境
- 操作系统:Windows10
- R:ver4.1.0
- RcppArmadillo:ver0.10.5.0.0
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)