[英]Rcpp inline package error in compileCode
I have R installed along with these two packages Rcpp and inline. 我已经安装了R和这两个软件包Rcpp和inline。 (I am doing a project that consists of speeding up a painfully slow program in R and I decided to use Rcpp)...I know I am doing something wrong...probably missing a step but i cannot figure it out.
(我正在做一个旨在加速R中缓慢而缓慢的程序的项目,所以我决定使用Rcpp)...我知道我做错了事...可能错过了一步,但我无法弄清楚。 Props to Dirk if you're reading this!
如果您正在阅读此书,请向德克(Dirk)提出建议! Thanks for Rcpp and the brand new inline package pdf but...it's still not running.
感谢Rcpp和全新的内联软件包pdf,但是...它仍然没有运行。 Please note that I'm a newbie.
请注意,我是新手。 As stated before I cleaned out all other packages and only R is installed with Rcpp and inline (of course I have c++ installed as well).
如前所述,我清除了所有其他软件包,只有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
If it is the construction of a package skeleton missing: i tried the simple rcpp_hello_world() example: 如果是缺少包框架的构造:我尝试了简单的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:.
The rest was a long list of odd symbols but what I could read was the name of c++ projects I have, I didn't include them as it would be too lengthy 其余的是一长串奇数符号,但是我能读的是我拥有的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"
Anything would help please, also I have linux installed as well so if that is a better option please do tell. 任何东西都请帮忙,我也安装了linux,所以如果这是一个更好的选择,请告诉我。 I am open to anything right now, the slightest progress makes is a delight
我现在对任何事情都敞开心the,一点点进步就是一种喜悦
Do you actually have a Fortran compiler installed? 您实际上安装了Fortran编译器吗?
If you don't, or you don't know, try your Linux box. 如果您不知道,或者不知道,请尝试使用Linux。 R on Windows must be able to compile source packages if you want to build with Rcpp and inline.
如果要使用Rcpp和内联进行构建,则Windows上的R 必须能够编译源程序包。 A good quick test is to try something like
一个很好的快速测试是尝试类似
R> myroot <- cppFunction('double myroot(double x) { return ::sqrt(x); }')
R> myroot(16)
[1] 4
R>
or equivalently via inline (where rcpp
is a wrapper for the cxxfunction(..., plugin="Rcpp")
call, you need the most recent inline package for that) 或等效地通过内联(其中
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>
If this does not work, read up on the R basics of installing Rtools for Windows etc. We have a few additional notes in the Rcpp FAQ as well. 如果这不起作用,请阅读安装Windows Rtools的R基础知识。Rcpp FAQ中也有一些其他说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.