我正在运行 64 位 Windows 7 平台。
\n\n我已添加到我安装的程序/库中:
\n\n实时工具
R(软件)
Rcpp(R包)
内联(R 包)
我尝试了这里找到的一个片段
\n\n## now with Rcpp and C++\nlibrary(inline)\n# and de\xef\xac\x81ne our version in C++\nsrc <- "int n = as<int>(ns);\ndouble x = as<double>(xs);\nfor (int i=0; i<n; i++) x=1/(1+x);\nreturn wrap(x); "\nl <- cxxfunction(signature(ns="integer", xs="numeric"),\nbody=src, plugin="Rcpp")\nRun Code Online (Sandbox Code Playgroud)\n\n但这不起作用(说实话,这并不奇怪,因为我什至没有指定例如 Rtools 的位置)。我收到以下错误消息:
\n\nError in system(cmd, intern = !verbose) : \'C:/Program\' not found\nRun Code Online (Sandbox Code Playgroud)\n\n我不确定这意味着什么。而且,我已经被困在那里几个小时了。有人可以帮我一点吗?
\n根据 nograpes 的建议,我得到:
>> setting environment variables:
PKG_LIBS = C:/Users/ (...) /DOCUME~1/R/WIN-LI~1/3.0/Rcpp/lib/x64/libRcpp.a
>> LinkingTo : Rcpp
CLINK_CPPFLAGS = -I"C:/Users/ (...) /Documents/R/win-library/3.0/Rcpp/include"
>> 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 file47844fc6c7a( SEXP ns, SEXP xs) ;
24 : }
25 :
26 : // definition
27 :
28 : SEXP file47844fc6c7a( SEXP ns, SEXP xs ){
29 : BEGIN_RCPP
30 : int n = as<int>(ns);
31 : double x = as<double>(xs);
32 : for (int i=0; i<n; i++) x=1/(1+x);
33 : return wrap(x);
34 : END_RCPP
35 : }
36 :
37 :
Compilation argument:
C:/Program Files/R-3.0.1/bin/x64/R CMD SHLIB file47844fc6c7a.cpp 2> file47844fc6c7a.cpp.err.txt
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file 'file47844fc6c7a.cpp.err.txt': No such file or directory
Run Code Online (Sandbox Code Playgroud)
但是,我承认这对我没有多大帮助。