拿了去年R会议东东学习,中国科学技术大学的黄金山干货,遇到些问题,如下:
> as.src<-'
+ std::vector<int>intvec=as<std::vector<int>>(intx);
+ //wrong way!std::vector<int> impvec(intx);
+ int N=as<int>(n);
+ int m=Rf_asInteger(n);//Rf_as*** is C API
+ List lst(N);
+ lst[0]=intvec;lst[1]=m;
+ return lst;
+ '
> as.test<-cxxfunction(signature(intx="integer",
+ n="integer"),
+ as.src,plugin="Rcpp")
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-215~1.3/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-215~1.3/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
filed2c20564c0f.cpp: In function 'SEXPREC* filed2c20564c0f(SEXP, SEXP)':
filed2c20564c0f.cpp:31:42: error: '>>' should be '> >' within a nested template argument list
make: *** [filed2c20564c0f.o] Error 1
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 filed2c20564c0f( SEXP intx, SEXP n) ;
24: }
25:
26: // definition
27:
28: SEXP filed2c20564c0f( SEXP intx, SEXP n ){
29: BEGIN_RCPP
30:
31: std::vector<int>intvec=as<std::vector<int>>(intx);
32: //wrong way!std::vector<int> impvec(intx);
33: int N=as<int>(n);
34: int m=Rf_asInteger(n);//Rf_as*** is C API
35: List lst(N);
36: lst[0]=intvec;lst[1]=m;
37: return lst;
38:
39: END_RCPP
40: }
41:
42:
错误于compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-215~1.3/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-215~1.3/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
filed2c20564c0f.cpp: In function 'SEXPREC* filed2c20564c0f(SEXP, SEXP)':
filed2c20564c0f.cpp:31:42: error: '>>' should be '> >' within a nested template argument list
make: *** [filed2c20564c0f.o] Error 1
此外: 警告信息:
运行命令'C:/PROGRA~1/R/R-215~1.3/bin/i386/R CMD SHLIB filed2c20564c0f.cpp 2> filed2c20564c0f.cpp.err.txt'的状态是1
> intx<-1:10;n<-2
> as.test(intx,n)
错误: 没有"as.test"这个函数
> //conversion from R to C++
错误: 意外的'/'在"/"里
> template <typename T> T as (SEXP m_sexp)
错误: 意外的符号在" template <typename T"里
> wrap.src<-'
+ std::vector<-std::map<std::string,int>>v;
+ std::map<std::string,int>m1;
+ std::map<std::string,int>m2;
+ m1["foo"]=1;m1["bar"]=2;
+ m2["foo"]=1;m2["bar"]=2;m2["baz"]=3;
+ v.push_back(m1);v.push_back(m2);
+ return wrap(v);
+ '
> wrap.test<-cxxfunction(signature(),wrap.src,plugin="Rcpp")
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-215~1.3/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-215~1.3/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
filed2c773b400c.cpp: In function 'SEXPREC* filed2c773b400c()':
filed2c773b400c.cpp:31:38: error: '>>' should be '> >' within a nested template argument list
filed2c773b400c.cpp:31:38: error: template argument 1 is invalid
filed2c773b400c.cpp:31:38: error: template argument 2 is invalid
filed2c773b400c.cpp:31:41: error: invalid type in declaration before ';' token
filed2c773b400c.cpp:36:3: error: request for member 'push_back' in 'v', which is of non-class type 'int'
filed2c773b400c.cpp:36:19: error: request for member 'push_back' in 'v', which is of non-class type 'int'
make: *** [filed2c773b400c.o] Error 1
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 filed2c773b400c( ) ;
24: }
25:
26: // definition
27:
28: SEXP filed2c773b400c( ){
29: BEGIN_RCPP
30:
31: std::vector<-std::map<std::string,int>>v;
32: std::map<std::string,int>m1;
33: std::map<std::string,int>m2;
34: m1["foo"]=1;m1["bar"]=2;
35: m2["foo"]=1;m2["bar"]=2;m2["baz"]=3;
36: v.push_back(m1);v.push_back(m2);
37: return wrap(v);
38:
39: END_RCPP
40: }
41:
42:
错误于compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-215~1.3/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-215~1.3/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
filed2c773b400c.cpp: In function 'SEXPREC* filed2c773b400c()':
filed2c773b400c.cpp:31:38: error: '>>' should be '> >' within a nested template argument list
filed2c773b400c.cpp:31:38: error: template argument 1 is invalid
filed2c773b400c.cpp:31:38: error: template argument 2 is invalid
filed2c773b400c.cpp:31:41: error: invalid type in declaration before ';' token
filed2c773b400c.cpp:36:3: error: request for member 'push_back' in 'v', which is of non-class type 'int'
filed2c773b400c.cpp:36:19: error: request for member 'push_back' in 'v', which is of non-c
此外: 警告信息:
运行命令'C:/PROGRA~1/R/R-215~1.3/bin/i386/R CMD SHLIB filed2c773b400c.cpp 2> filed2c773b400c.cpp.err.txt'的状态是1
> wrap.test()
错误: 没有"wrap.test"这个函数