在Windows下构build(并运行)RInside示例

我对RInside + Rcpp + R + C ++ + windows的故事相当陌生。 我试图通过成功编译和运行RInside的例子来解决问题。 我设法克服了许多最初的问题(比如这个 ),最后设法构build了64位的RInside示例可执行文件。

我正在运行最新版本的R最新版本的RTools。 我通过运行从源码build立了RInside和RCPP

install.packages(c("Rcpp","RInside"),type="source") 

否则,我只能够build立x86二进制文件(我不能在我的64位Windows服务器操作系统上运行)。 从R控制台一切正常。 以下示例传递没有任何错误:

 body <- ' + NumericVector xx(x); + return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));' > > add <- cxxfunction(signature(x = "numeric"), body, plugin = "Rcpp") cygwin warning: MS-DOS style path detected: C:/R-215~1.0/etc/x64/Makeconf Preferred POSIX equivalent is: /cygdrive/c/R-215~1.0/etc/x64/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 > > x <- 1 > y <- 2 > res <- add(c(x, y)) > res [1] 3 > #[1] 3 

但是,当我尝试运行RInside的例子,我得到以下错误:

 Error in paste0("(^|[^%])(%%)*%", spec) : not a BUILTIN function Error in paste0("^", pkg, "$") : not a BUILTIN function Execution halted 

有没有人有什么想法是怎么回事?

非常感谢。

编辑:更详细的问题与R 2.15.0 repro。

我安装了从CRAN到C:\ R-2.15.0 Ran 64bit RGUI.exe的最新版本,然后执行install.packages(c("Rcpp","RInside"),type="source")按顺序更改了Makefile.win强制x64体系结构并指向正确的安装目录。

 ## -*- mode: makefile; tab-width: 8; -*- ## ## Simple Makefile for Windows ## This version is fairly directly derived from the Unix versions ## You may have to set R_HOME manually if this does not work ## It requires Rtools in the path -- as does all R package building #R_HOME := $(shell R RHOME | sed -e "s|\\\\|\/|g") R_HOME := "C:\R-2.15.0" #R_HOME := "C:\R-2.14.1" #R_HOME := "C:\R-2.14.2" ## You may have to set this to one of the two values to enforce a particular architecture #R_ARCH := --arch i386 R_ARCH := --arch x64 sources := $(wildcard *.cpp) programs := $(sources:.cpp=) ## include headers and libraries for R RCPPFLAGS := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config --cppflags) RLDFLAGS := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config --ldflags) RBLAS := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config BLAS_LIBS) RLAPACK := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config LAPACK_LIBS) ## include headers and libraries for Rcpp interface classes RCPPINCL := $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave) RCPPLIBS := $(shell echo 'Rcpp:::LdFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave) ## include headers and libraries for RInside embedding classes RINSIDEINCL := $(shell echo 'RInside:::CxxFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave) RINSIDELIBS := $(shell echo 'RInside:::LdFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave) ## compiler etc settings used in default make rules CXX := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXX) CPPFLAGS := -Wall $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CPPFLAGS) CXXFLAGS := $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXXFLAGS) LDFLAGS = -s LDLIBS := $(RLDFLAGS) $(RBLAS) $(RLAPACK) $(RINSIDELIBS) $(RCPPLIBS) CC := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXX) all : $(programs) clean: rm -vf $(programs) checkR: echo "R is at $(R_HOME)" 

运行make -f Makefile.win

 cygwin warning: MS-DOS style path detected: C:\R-2.15.0/bin/R Preferred POSIX equivalent is: /cygdrive/c/R-2.15.0/bin/R 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 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s atomic.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2 .15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside.a" C:/R- 2.15.0/library/Rcpp/lib/x64/libRcpp.a -o atomic g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_callbacks0.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRb las -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRIns ide.a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_callbacks0 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_module_sample0.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/lib RInside.a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_module_sample0 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample0.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample0 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample1.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample1 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample10.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRbla s -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInsid ea" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample10 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample11.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRbla s -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInsid ea" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample11 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample2.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample2 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample3.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample3 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample4.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample4 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample5.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample5 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample6.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample6 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample7.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample7 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample8.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample8 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_sample9.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas -LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside .a" C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_sample9 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_test0.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas - LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside.a " C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_test0 g++ -m64 -IC:/R-2.15.0/include -IC:/R-2.15.0/include/x64 -IC:/R-2.15.0/library/R cpp/include -IC:/R-2.15.0/library/RInside/include -O2 -Wall -mtune=core2 -Wall -s rinside_test1.cpp -LC:/R-2.15.0/bin/x64 -lR -LC:/R-2.15.0/bin/x64 -lRblas - LC:/R-2.15.0/bin/x64 -lRlapack "C:/R-2.15.0/library/RInside/lib/x64/libRInside.a " C:/R-2.15.0/library/Rcpp/lib/x64/libRcpp.a -o rinside_test1 

我得到了可执行文件,但是当我尝试运行其中任何一个时,出现以下错误。

 Error in paste0("(^|[^%])(%%)*%", spec) : not a BUILTIN function Error in paste0("^", pkg, "$") : not a BUILTIN function Execution halted 

Solutions Collecting From Web of "在Windows下构build(并运行)RInside示例"

请在rcpp-devel邮件列表中发布一个完整且可重复的示例 。 请注意,您需要订阅帖子上的名单; 否则使用像Gmane订阅它的东西 。

由于我们解决了初始化问题,RInside肯定能够在Windows下工作。 你必须输入make -f Makefile.win ,而不是仅仅make 。 发布具有可重现源的完整命令,以及完整的错误日志。

对不起,我花了这么长时间来重温这个问题。

最后,我回到了以前版本的R(2.14.2),它开箱即用。 所以我想用2.15.1.0和RInside协作是有问题的。 如果我找到一些时间,我会试着进一步调查。