2012-03-19 111 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)。在某种程度上,你的编译器/链接器不喜欢那个空格。

相关问题