[英]Rcpp inline package error in compileCode
我已经安装了R和这两个软件包Rcpp和inline。 (我正在做一个旨在加速R中缓慢而缓慢的程序的项目,所以我决定使用Rcpp)...我知道我做错了事...可能错过了一步,但我无法弄清楚。 如果您正在阅读此书,请向德克(Dirk)提出建议! 感谢Rcpp和全新的内联软件包pdf,但是...它仍然没有运行。 请注意,我是新手。 如前所述,我清除了所有其他软件包,只有R和Rcpp以及内联一起安装了R(当然,我也安装了c ++)。
library(Rcpp)
library(inline)
x<-as.numeric(1:10)
n<-as.integer(10)
code<-"
integer i
do 1 i=1, n(1)
1 x(i)=x(i)**3
"
cubefn<- cfunction(signature(n="integer",x="numeric"),code,convention=".Fortran")
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
1: #include <R.h>
2:
3:
4: extern "C" {
5: void filef2424e34d61 ( int * n, double * x );
6: }
7:
8: void filef2424e34d61 ( int * n, double * x ) {
9:
10: integer i
11: do 1 i=1, n(1)
12: 1 x(i)=x(i)**3
13:
14: }
Error in compileCode(f, code, language, verbose) :
Compilation ERROR, function(s)/method(s) not created!
In addition: Warning message:
running command 'C:/R/R-2.15.2/bin/x64/R CMD SHLIB filef2424e34d61.cpp 2> filef2424e34d61.cpp.err.txt' had status 1
如果是缺少包框架的构造:我尝试了简单的rcpp_hello_world()示例:
rcpp_hello_world <- function(){
.Call( "rcpp_hello_world", PACKAGE = "mypackage" )
}
Folder PATH listing for volume OS
Volume serial number is 769C-A616
C:.
其余的是一长串奇数符号,但是我能读的是我拥有的c ++项目的名称,因为它太长了,所以我没有包括它们
rcpp_hello_world <-function(){
.Call("rcpp_hello_world",PACKAGE="mypackage")
}
rcpp_hello_world()
Error in .Call("rcpp_hello_world", PACKAGE = "mypackage") :
"rcpp_hello_world" not available for .Call() for package "mypackage"
任何东西都请帮忙,我也安装了linux,所以如果这是一个更好的选择,请告诉我。 我现在对任何事情都敞开心the,一点点进步就是一种喜悦
您实际上安装了Fortran编译器吗?
如果您不知道,或者不知道,请尝试使用Linux。 如果要使用Rcpp和内联进行构建,则Windows上的R 必须能够编译源程序包。 一个很好的快速测试是尝试类似
R> myroot <- cppFunction('double myroot(double x) { return ::sqrt(x); }')
R> myroot(16)
[1] 4
R>
或等效地通过内联(其中rcpp
是cxxfunction(..., plugin="Rcpp")
调用的包装器,您需要用于此的最新内联包)
R> myroot2 <- rcpp(signature(xs="numeric"),
+ body='double x=as<double>(xs); return wrap(::sqrt(x));')
R> myroot2(16)
[1] 4
R>
如果这不起作用,请阅读安装Windows Rtools的R基础知识。Rcpp FAQ中也有一些其他说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.