我对RInside + Rcpp + R + C ++ + windows故事很陌生。我试图通过成功编译和运行RInside示例来实现目标。我设法克服了许多初始问题(如this one),最终成功构建了64位RInside示例可执行文件。
我正在运行最新版本的R R最新版本的RTools。我通过运行
从源代码构建了RInside和RCPPinstall.packages(c("Rcpp","RInside"),type="source")
否则我只能构建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问题重复。
我从CRAN安装了最新版本到C:\ R-2.15.0
跑64位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)"
Ran 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
e.a" 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
e.a" 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
答案 0 :(得分:2)
请将完整且可重现的示例发布到rcpp-devel mailing list。请注意,您需要订阅帖子列表;否则使用Gmane subscription to it之类的东西。
由于我们修复了初始化问题,因此RInside绝对适用于Windows。您必须输入make -f Makefile.win
,而不仅仅是make
。发布具有可重现源和完整错误日志的完整命令。
答案 1 :(得分:0)
很抱歉,我花了很长时间才重新审视这个问题。
最后,我回到了之前版本的R(2.14.2),开箱即用。所以我猜2.15.1.0和RInside合作存在一些问题。如果我找到一些时间,我会尝试进一步调查。