2012-09-22 7 views
2

Windows 7에서 R 2.15.1을 사용하고 있는데 다음 R 코드를 실행하면 오류 메시지가 나타납니다. 누구가 나를 도울까요?인라인 및 Rcpp 패키지의 오류

> library(inline) 
> 
> if(require(Rcpp)){ 
+ fx <- cxxfunction(signature(x = "integer", y = "numeric") , ' 
+ return wrap(as<int>(x) * as<double>(y)) ; 
+ ', plugin = "Rcpp") 
+ } 
Loading required package: Rcpp 
cygwin warning: 
    MS-DOS style path detected: C:/R/R-215~1.1/etc/i386/Makeconf 
    Preferred POSIX equivalent is: /cygdrive/c/R/R-215~1.1/etc/i386/Makeconf 
    CYGWIN environment variable option "nodosfilewarning" turns off this warning. 
    Consult the user's guide for more details about POSIX paths: 
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames 
    Syntax error: "(" unexpected (expecting "fi") 
    make: *** [file11a82c84184d.dll] Error 2 

ERROR(s) during compilation: source code errors or compiler configuration errors! 

Program source: 
    1: 
    2: // includes from the plugin 
    3: 
    4: #include <Rcpp.h> 
    5: 
    6: 
    7: #ifndef BEGIN_RCPP 
    8: #define BEGIN_RCPP 
    9: #endif 
10: 
11: #ifndef END_RCPP 
12: #define END_RCPP 
13: #endif 
14: 
15: using namespace Rcpp; 
16: 
17: 
18: // user includes 
19: 
20: 
21: // declarations 
22: extern "C" { 
23: SEXP file11a82c84184d(SEXP x, SEXP y) ; 
24: } 
25: 
26: // definition 
27: 
28: SEXP file11a82c84184d(SEXP x, SEXP y){ 
29: BEGIN_RCPP 
30: 
31: return wrap(as<int>(x) * as<double>(y)) ; 
32: 
33: END_RCPP 
34: } 
35: 
36: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
    Compilation ERROR, function(s)/method(s) not created! cygwin warning: 
    MS-DOS style path detected: C:/R/R-215~1.1/etc/i386/Makeconf 
    Preferred POSIX equivalent is: /cygdrive/c/R/R-215~1.1/etc/i386/Makeconf 
    CYGWIN environment variable option "nodosfilewarning" turns off this warning. 
    Consult the user's guide for more details about POSIX paths: 
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames 
Syntax error: "(" unexpected (expecting "fi") 
make: *** [file11a82c84184d.dll] Error 2 
In addition: Warning message: 
running command 'C:/R/R-2.15.1/bin/i386/R CMD SHLIB file11a82c84184d.cpp 2> file11a82c84184d.cpp.err.txt' had status 1 
> 
+0

아래의 Dirk의 답변 외에도 저자에게 문제가있는 곳에서이 게시물을 팔로우 할 수 있습니다. http://www.r-bloggers.com/installing-rcpp-on-windows-7-for-r-and-c-integration/ –

+1

이것은 복잡한 게시물입니다. Windows 용 R 컴파일러 설치 방법은 수십 개의 자습서에서 설명합니다. 즉, Cygwin과 섞지 마십시오. –

답변

2

(나는 작은 변화/단순화를 만든 불구하고) 리눅스에서 현재 작동 :

R> library(inline) 
R> fx <- cxxfunction(signature(x = "integer", y = "numeric"), 
+     body = 'return wrap(as<int>(x) * as<double>(y));', 
+     plugin = "Rcpp") 
R> print(fx(2, 2.5)) 
R> [1] 5 
R> 

당신이 Windows에서 라인 노이즈를 조금 덜 받게됩니다 CYGWINnodosfilewarning에 변수 환경을 설정합니다.

+0

고맙습니다.하지만 환경 변수에 대해서는 잘 모릅니다. 방금 Windows 7에 R, R 도구 및 CYGWIN을 설치했습니다. – user1690124

+1

Windows 컴퓨터의 관리에 대해 알아야 할 수도 있습니다 ... –