繁体   English   中英

如何让Rcpp在Windows XP平台上运行?

[英]How to get Rcpp to work in R on a Windows XP platform?

我一直在尝试在Windows XP平台上使用R 2.14.2中的Rcpp。 据我所知,我遵循了使Rcpp工作的所有建议步骤:

  1. 我在一个名为C:\\ R \\ R-2.14.2的目录中安装了R;
  2. 我在目录C:\\ R \\ Rtools中安装了最新版本的Rtools;
  3. 我将环境PATH设置为以下(以完全相同的顺序):

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是否有效时,我收到了一条错误消息。 这是测试示例:

library(Rcpp)
library(inline)

body <- '
NumericVector xx(x);
return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));'

add <- cxxfunction(signature(x = "numeric"), body, plugin = "Rcpp")

x <- 1
y <- 2
res <- add(c(x, y))
res

这是由于尝试执行上述R代码而由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

不要在包含路径名称中的空格的目录中安装R。 我记得,这个建议是在'R for Windows FAQ'中。

我个人的偏好始终是c:\\opt\\R-current\\而不是版本化的默认路径。

您发布的消息的最后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 )。 在某种程度上,您的编译器/链接器不喜欢该空格。

我在设置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警告。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM