编译代码中的RCPP内联包错误 [英] Rcpp inline package error in compileCode

查看:146
本文介绍了编译代码中的RCPP内联包错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我同时安装了R和这两个软件包Rcpp和inline. (我正在做一个旨在加速R中缓慢而缓慢的程序的项目,所以我决定使用Rcpp)...我知道我做错了事...可能错过了一步,但我无法弄清楚.如果您正在阅读此书,请向德克(Dirk)提出建议!感谢Rcpp和全新的内联软件包pdf,但是...它仍然没有运行. 请注意,我是新手.如前所述,我清除了所有其他软件包,只有R和Rcpp以及内联一起安装了R(当然,我也安装了c ++).

I have R installed along with these two packages Rcpp and 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. Props to Dirk if you're reading this! Thanks for Rcpp and the brand new inline package pdf but...it's still not running. 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).

    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()示例:

If it is the construction of a package skeleton missing: i tried the simple rcpp_hello_world() example:

    rcpp_hello_world <- function(){

    .Call( "rcpp_hello_world", PACKAGE = "mypackage" )
    }

    Folder PATH listing for volume OS
    Volume serial number is 769C-A616
    C:.

其余的是一长串奇数符号,但是我能读的是我拥有的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

    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,所以如果这是一个更好的选择,请告诉我.我现在对任何事情都持开放态度,取得的一点进展都是令人高兴的

Anything would help please, also I have linux installed as well so if that is a better option please do tell. I am open to anything right now, the slightest progress makes is a delight

推荐答案

您实际上安装了Fortran编译器吗?

Do you actually have a Fortran compiler installed?

如果不知道或不知道,请尝试使用Linux.如果要使用Rcpp和内联进行构建,则Windows上的R 必须能够编译源程序包.一个不错的快速测试是尝试

If you don't, or you don't know, try your Linux box. R on Windows must be able to compile source packages if you want to build with Rcpp and inline. 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> 

或等效地通过内联(其中rcppcxxfunction(..., plugin="Rcpp")调用的包装,您需要用于此的最新内联软件包)

or equivalently via inline (where rcpp is a wrapper for the cxxfunction(..., plugin="Rcpp") call, you need the most recent inline package for that)

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基础知识.RcppFAQ中也有一些其他说明.

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.

这篇关于编译代码中的RCPP内联包错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆