2012-03-19 109 views
4

我一直在嘗試在Windows XP平臺上使用R 2.14.2中的Rcpp。據我所知,我遵循所有推薦的步驟讓Rcpp工作:如何在Windows XP平臺上讓Rcpp在R中工作?

  1. 我將R安裝在一個名爲C:\ R \ R-2.14.2的目錄中;
  2. 我在目錄C:\ R \ Rtools中安裝了最新版本的Rtools;
  3. 我環境路徑設置爲以下(在此以相同的順序):

C:\ r \ Rtools \ BIN; C:\ r \ Rtools \ GCC-4.6.3 \ bin中;
C:\ r \ R-2.14.2 \ BIN \ i386的; C:\ WINDOWS; C:\窗口\ system32

儘管所有的這一點,當我試圖運行中的R到測試實例看看Rcpp是否工作,我收到一條錯誤消息。以下是測試示例:

​​

這是由於嘗試執行上面的R代碼而產生的相當長的錯誤消息。任何人都可以告訴我什麼是我做錯了,我還需要做些什麼來確保Rcpp的工作?

cygwin warning: 
MS-DOS style path detected: C:/R/R-214~1.2/etc/i386/Makeconf 
Preferred POSIX equivalent is: /cygdrive/c/R/R-214~1.2/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 
g++.exe: error: C:/Documents: No such file or directory 
g++.exe: error: and: No such file or directory 
g++.exe: error: Settings/dv6110ca/My: No such file or directory 
g++.exe: error: Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a: No such file 
or directory 

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 file684203c3ec2(SEXP x) ; 
24: } 
25: 
26: // definition 
27: 
28: SEXP file684203c3ec2(SEXP x){ 
29: BEGIN_RCPP 
30: 
31: NumericVector xx(x); 
32: return wrap(std::accumulate(xx.begin(), xx.end(), 0.0)); 
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-214~1.2/etc/i386/Makeconf 
Preferred POSIX equivalent is: /cygdrive/c/R/R-214~1.2/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 
g++.exe: error: C:/Documents: No such file or directory 
g++.exe: error: and: No such file or directory 
g++.exe: error: Settings/dv6110ca/My: No such file or directory 
g++.exe: error: Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a: No such file or 
directory 

回答

4

包含路徑名稱中的空格的目錄中沒有安裝R。我記得那個建議是在'R for Windows FAQ'中。

我個人偏好總是c:\opt\R-current\而不是版本化的默認路徑。

2

我在設置Rcpp時遇到了同樣的問題。它看起來像你卸載了R然後重新安裝它來創建一個與Rcpp兼容的設置。當你這樣做時,R會將軟件包安裝在與以前的安裝相同的文件夾中。卸載R後,請確保您刪除包含軟件包的文件夾。在我的Windows 7機器上,這是文件夾位於C:/Users/Chandler/R。刪除此文件夾;然後重新安裝R.確保在新的R文件夾中安裝了新的軟件包,例如C:\R\R-2.14.2\library。這應該可以消除Dirk上面提到的文件夾位置中的空間問題。

另外,請確保路徑與「R安裝和管理」手冊附錄D中的示例相同。如果您使用R的最新版本而不是2.14.2,則最容易遵循本手冊

注意:即使Rcpp正常工作,我仍然會收到cygwin警告。

+2

也許聲明'CYGWIN環境變量選項「nodosfilewarning」關閉此警告。 '(在OP發佈的消息的中間)可以幫助關閉警告。 – 2012-10-07 13:21:19

3

的誤差在過去的5行您發佈的消息的解釋:

g++.exe: error: C:/Documents: No such file or directory 
g++.exe: error: and: No such file or directory 
g++.exe: error: Settings/dv6110ca/My: No such file or directory 
g++.exe: error: Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a: No such file or 
directory 

g++.exe正在尋找一個名爲libRcpp.a但該文件是在其名稱包含空格的文件夾中,特別是在您的計算機中的文件是此文件夾中:

C:/Documents and Settings/dv6110ca/My Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a 

和文件夾的路徑中包含3個空格(Documentsand之間,andSettings之間,之間MyDocuments)。在某種程度上,你的編譯器/鏈接器不喜歡那個空格。

相關問題