楼主: wxc0429
4964 4

[问答] 连接C++的Rcpp包一直用不好 [推广有奖]

  • 4关注
  • 20粉丝

博士生

78%

还不是VIP/贵宾

-

威望
0
论坛币
9738 个
通用积分
7.7408
学术水平
23 点
热心指数
29 点
信用等级
20 点
经验
10709 点
帖子
177
精华
0
在线时间
330 小时
注册时间
2008-3-7
最后登录
2023-10-29

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
rcpp.txt (1.06 KB) 我按照一个网上的案例来做的,结果总是提示错误。好像在编译器上,我用的编译器是vc6.0,在windows 7下运行。请大家运行下附件中的代码,帮我看看问题处在哪里了。

我运行的结果如下:
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 file3bfc83e( SEXP n_, SEXP width_, SEXP format_) ;
24: }
25:
26: // definition
27:
28: SEXP file3bfc83e( SEXP n_, SEXP width_, SEXP format_ ){
29: BEGIN_RCPP
30:
31:
32:         int n = as(n_) ;
33:         int width = as( width_ ) ;
34:         const char* format = as( format_ ) ;
35:         
36:         std::string buffer( width, '0' ) ;
37:         std::vector< std::string > elements( n ) ;
38:         for( int i=0; i( buffer.data() ),
39:                 format,
40:                 i+1
41:             ) ;
42:             elements = buffer.c_str() ;
43:         }
44:         
45:         std::stringstream ss ;
46:         
47:         
48:         CharacterVector res( n*(n-1)/2) ;
49:         for( int i=0, k=0; i<n-1; i++){
50:             for( int j=i+1; j<n; j++, k++){
51:                 ss << "i" << elements << "." << elements[j] ;
52:                 res[k] = ss.str() ;
53:                 ss.str("") ;
54:             }
55:         }
56:         
57:         return res ;
58:     
59: END_RCPP
60: }
61:
62:
Error in compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created!
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-213~1.1/bin/i386/R CMD SHLIB file3bfc83e.cpp 2> file3bfc83e.cpp.err.txt' had status 1
>

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Rcpp Compilation Declaration definition Character includes windows errors during source

所谓模型,就是用统计语言简化了的现实世界;越贴近实际情况,效果越佳。
沙发
xiongxiangbiao 发表于 2011-11-16 22:42:42 |只看作者 |坛友微信交流群
什么玩意儿!

使用道具

藤椅
soccy 发表于 2011-11-16 23:09:22 |只看作者 |坛友微信交流群
Rcpp only works with the GNU toolchain.

使用道具

板凳
wxc0429 发表于 2011-11-18 00:06:39 |只看作者 |坛友微信交流群
soccy 发表于 2011-11-16 23:09
Rcpp only works with the GNU toolchain.
那应该用什么编辑器?莫非一定要在lunix下面跑?
所谓模型,就是用统计语言简化了的现实世界;越贴近实际情况,效果越佳。

使用道具

报纸
soccy 发表于 2011-11-18 02:20:44 |只看作者 |坛友微信交流群

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-1 18:19