簡體   English   中英

compileCode中的RCPP內聯包錯誤

[英]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> 

或等效地通過內聯(其中rcppcxxfunction(..., 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM