Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rcpp编译错误_R_Rcpp - Fatal编程技术网

Rcpp编译错误

Rcpp编译错误,r,rcpp,R,Rcpp,我试图运行测试函数,但遇到编译错误: library(Rcpp) library(inline) testfun = cxxfunction( signature(x="numeric", i="integer"), body = ' NumericVector xx(x); int ii = as<int>(i); xx = xx * ii; return( xx ); ', plugin="Rcpp") testfun(1:5, 3)

我试图运行测试函数,但遇到编译错误:

library(Rcpp)  
library(inline) 

testfun = cxxfunction(  
signature(x="numeric", i="integer"),  
body = '  
NumericVector xx(x);    
int ii = as<int>(i);  
xx = xx * ii;  
return( xx );  
', plugin="Rcpp")  
testfun(1:5, 3)  
库(Rcpp)
库(内联)
testfun=CXX函数(
签名(x=“数字”,i=“整数”),
身体
数值向量xx(x);
int ii=as(i);
xx=xx*ii;
返回(xx);
,plugin=“Rcpp”)
测试乐趣(1:5,3)
编译代码中出错(f,代码,语言=语言,详细=详细): 编译错误,未创建函数/方法! 此外:警告信息: 运行命令“C:/PROGRA~1/R/R-215~1.1/bin/x64/R CMD SHLIB filede44a566900.cpp 2>filede44a566900.cpp.err.txt”的状态为1


我将非常感谢你的帮助。我正在使用windows 7,R2.15.1,64位

尝试添加
verbose=TRUE
,因为您似乎有一个简单的设置问题——可能是您的路径不正确

您的代码是正确的,并且在Linux下运行得很好(在Linux下,不需要像在Windows上那样做额外的练习)

从my Emacs ESS缓冲区复制的稍微编辑/缩进的示例:

R> library(inline)
R> 
R> testfun <- cxxfunction(signature(x="numeric", i="integer"), body = '
+    NumericVector xx(x);
+    int ii = as<int>(i);
+    xx = xx * ii;
+    return( xx );
+ ', plugin="Rcpp")
R> 
R> testfun(1:5, 3)
[1]  3  6  9 12 15
R> 
R>库(内联)
R>
R> 测试乐趣
R> 测试乐趣(1:5,3)
[1]  3  6  9 12 15
R>

尝试添加
verbose=TRUE
,因为您似乎有一个简单的设置问题——可能您的路径不正确

您的代码是正确的,并且在Linux下运行得很好(在Linux下,不需要像在Windows上那样做额外的练习)

从my Emacs ESS缓冲区复制的稍微编辑/缩进的示例:

R> library(inline)
R> 
R> testfun <- cxxfunction(signature(x="numeric", i="integer"), body = '
+    NumericVector xx(x);
+    int ii = as<int>(i);
+    xx = xx * ii;
+    return( xx );
+ ', plugin="Rcpp")
R> 
R> testfun(1:5, 3)
[1]  3  6  9 12 15
R> 
R>库(内联)
R>
R> 测试乐趣
R> 测试乐趣(1:5,3)
[1]  3  6  9 12 15
R>

您正在使用cygwin吗?检查它是否配置正确?使用什么编译器版本?我以前也有过类似的问题,因为链接错误。你用的是cygwin吗?检查它是否配置正确?使用什么编译器版本?由于链接错误,我以前也遇到过类似的问题,特别是Cygwin不受支持。请注意,Cygwin不受支持。