如何让 Rcpp 在 Windows XP 平台上在 R 中工作? [英] How to get Rcpp to work in R on a Windows XP platform?
问题描述
我一直在尝试在 Windows XP 平台上使用 R 2.14.2 中的 Rcpp.据我所知,我遵循了让 Rcpp 正常工作的所有推荐步骤:
- 我将 R 安装在名为 C:\R\R-2.14.2 的目录中;
- 我在目录 C:\R\Rtools 中安装了最新版本的 Rtools;
- 我将环境 PATH 设置为以下(以完全相同的顺序):
<块引用>
C:\R\Rtools\bin;C:\R\Rtools\gcc-4.6.3\bin;
C:\R\R-2.14.2\bin\i386;C:\WINDOWS;C:\WINDOWS\system32
尽管如此,当我尝试在 R 中运行测试示例以查看 Rcpp 是否有效时,我收到了一条错误消息.这是测试示例:
库(Rcpp)图书馆(内联)正文 <-'数字向量 xx(x);return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));'添加 <- cxxfunction(signature(x = "numeric"), body, plugin = "Rcpp")x <- 1y <- 2res <- 添加(c(x, y))资源
这是由于尝试执行上述 R 代码而由 R 产生的相当长的错误消息.谁能告诉我我做错了什么,我还需要做什么来确保 Rcpp 正常工作?
cygwin 警告:检测到 MS-DOS 样式路径:C:/R/R-214~1.2/etc/i386/Makeconf首选的 POSIX 等效项是:/cygdrive/c/R/R-214~1.2/etc/i386/MakeconfCYGWIN 环境变量选项nodosfilewarning"关闭此警告.有关 POSIX 路径的更多详细信息,请参阅用户指南:http://cygwin.com/cygwin-ug-net/using.html#using-pathnamesg++.exe: 错误: C:/Documents: No such file or directoryg++.exe: 错误: 和: 没有那个文件或目录g++.exe: 错误: Settings/dv6110ca/My: No such file or directoryg++.exe: 错误: Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a: No such file或目录编译期间的错误:源代码错误或编译器配置错误!程序来源:1:2://包含来自插件3:4:#include 5:6:7:#ifndef BEGIN_RCPP8:#define BEGIN_RCPP9:#endif10:11:#ifndef END_RCPP12:#define END_RCPP13:#endif14:15:使用命名空间Rcpp;16:17:18://用户包括19:20:21://声明22:外部C"{23: SEXP 文件684203c3ec2( SEXP x) ;24:}25:26://定义27:28: SEXP 文件684203c3ec2( SEXP x ){29:BEGIN_RCPP30:31: 数字向量 xx(x);32:返回包装(std::accumulate(xx.begin(),xx.end(),0.0));33:END_RCPP34:}35:36:compileCode(f, code, language = language, verbose = verbose) 中的错误:编译错误,未创建函数/方法!cygwin警告:检测到 MS-DOS 样式路径:C:/R/R-214~1.2/etc/i386/Makeconf首选的 POSIX 等效项是:/cygdrive/c/R/R-214~1.2/etc/i386/MakeconfCYGWIN 环境变量选项nodosfilewarning"关闭此警告.有关 POSIX 路径的更多详细信息,请参阅用户指南:http://cygwin.com/cygwin-ug-net/using.html#using-pathnamesg++.exe: 错误: C:/Documents: No such file or directoryg++.exe: 错误: 和: 没有那个文件或目录g++.exe: 错误: Settings/dv6110ca/My: No such file or directoryg++.exe: 错误: Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a: No such file or目录
不要在路径名中包含空格的目录中安装 R.我记得,该建议在R for Windows 常见问题解答"中.
我个人的偏好总是 c:\opt\R-current\
而不是版本化的默认路径.
I've been trying to work with Rcpp in R 2.14.2 on a Windows XP platform. As far as I can tell, I followed all of the recommended steps for getting Rcpp to work:
- I installed R in a directory called C:\R\R-2.14.2;
- I installed the latest version of Rtools in the directory C:\R\Rtools;
- I set the environment PATH to the following (in this exact same order):
C:\R\Rtools\bin;C:\R\Rtools\gcc-4.6.3\bin;
C:\R\R-2.14.2\bin\i386;C:\WINDOWS;C:\WINDOWS\system32
Despite all of this, when I tried to run a test example in R to see if Rcpp works, I got an error message. Here is the test example:
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
Here is the rather long error message produced by R as a result of trying to execute the above R code. Can anyone tell me what it is that I am doing wrong and what else I need to do to make sure that Rcpp works?
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
Do not install R in a directory containing a space in the path name. That recommendation is, as I recall, in the 'R for Windows FAQ'.
My personally preference is always c:\opt\R-current\
instead of the versioned default path.
这篇关于如何让 Rcpp 在 Windows XP 平台上在 R 中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!