如何在 TDM-gcc 4.8.1 中使用 Rcpp? [英] How to use Rcpp with TDM-gcc 4.8.1?
问题描述
我在 Windows 7(32 位)下使用 R 3.0.2,路径中有 TDM-GCC-32(gcc (tdm-2) 4.8.1).
I'm using R 3.0.2 under Windows 7 (32bit) and has TDM-GCC-32 (gcc (tdm-2) 4.8.1) in the path.
当我尝试使用 cppFunction 时,出现一些错误:
When I try to use cppFunction, I get some error:
library(inline)
library(Rcpp)
src <- '
SEXP hellofun(){
std::vector<std::string> s;
s.push_back("hello");
s.push_back("world");
return Rcpp::wrap(s);
}'
hello_fun <- cppFunction(src)
错误信息:
Error in inDL(x, as.logical(local), as.logical(now), ...) (from file1c8c8c929f5.cpp.R#1) :
unable to load shared object 'C:/Users/ssss11/AppData/Local/Temp/RtmpeywSmo/sourcecpp_1c8c47543253/sourceCpp_60750.dll':
LoadLibrary failure: Invalid access to memory location
但是,当我运行 example(cfuntion) 时,它成功了.
However when I run example(cfuntion), it succeeds.
library(inline)
example(cfunction)
如何解决这个问题?
推荐答案
我不知道 TDM-GCC-32 (gcc (tdm-2) 4.8.1)
可能是什么 -- 但是我们的文档一再强调,Windows 上只支持一种编译器:Rtools 对应于您的 R 版本.
I have no idea what TDM-GCC-32 (gcc (tdm-2) 4.8.1)
may be -- but our documentation repeatedly stresses that one and only one compiler is support on Windows: the one that comes with the version of Rtools corresponding to your R version.
现在,TDM-gcc-32"可能与功能兼容,但如果您想使用它,您可能必须重建整个 R 堆栈(即 R 本身、所有包、...) 用它.
Now, 'TDM-gcc-32' may well be feature compatible, but if you want to use it you probably have to rebuild your entire R stack (ie R itself, all packages, ...) with it.
所以最好等待 R Core/CRAN 将 Rtools 更新到比 gcc-4.6 更新的版本.*
Sot it might be best to wait for R Core / CRAN to update Rtools to a version newer than gcc-4.6.*
这篇关于如何在 TDM-gcc 4.8.1 中使用 Rcpp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!