0

I am quite new to the RInside + Rcpp + R + C++ + windows story. I am trying to get things going by successfully compiling and running RInside examples. I managed to overcome many initial problems (like this one), and finally managed to build 64bit RInside example executables.

I am running the newest version of R the newest version of RTools. I built RInside and RCPP from source by running

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

Otherwise I was only able to build x86 binary (which I couldn't run on my 64bit windows server os). From R console everything works fine. Following example passed without any errors:

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

But when I try to run RInside examples I get following error:

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

Does anyone have any idea what is going on?

Thanks a lot in advance.

edit: More detailed repro of issue with R 2.15.0.

I installed latest build from CRAN to the C:\R-2.15.0 Ran 64bit RGUI.exe and executed install.packages(c("Rcpp","RInside"),type="source") Changed Makefile.win in order to force x64 architecture and to point to the correct install directory.

## -*- 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

I got executables, but when I try to run any of them I get following error.

Error in paste0("(^|[^%])(%%)*%", spec) : not a BUILTIN function
Error in paste0("^", pkg, "$") : not a BUILTIN function
Execution halted
Community
  • 1
  • 1
Klark
  • 8,162
  • 3
  • 37
  • 61

2 Answers2

2

Please post a complete and reproducible example to the rcpp-devel mailing list. Note that you need to subscribe to post on-list; otherwise use something like the Gmane subscription to it.

RInside definitely works under Windows since we fixed the initialization issue. You must type make -f Makefile.win though, and not just make. Post full commands with reproducible sources, and full error logs.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
0

Sorry it took me so long to revisit this problem.

At the end, I just turned back to the previous version of R (2.14.2) and it worked out of the box. So I guess there is some problem with 2.15.1.0 and RInside collaboration. I will try to investigate this further if I find some time.

Klark
  • 8,162
  • 3
  • 37
  • 61
  • There is no such thing as '2.15.1.0' and for all we know, RInside works just fine with the current (2.15.0) as well as previous versions of R. If you want help, you will have to do better. – Dirk Eddelbuettel May 22 '12 at 12:04
  • Yes, my mistake, it is 2.15.0. Switching to the 2.14.2 solved my problems (I am only creating a prototype, so I don't really care about version). I am still getting the same error with 2.15.0 following completely same procedure. Thanks for the help anyway. – Klark May 22 '12 at 14:03
  • I can only urge you to post the errors and a reproducible example to the list. R 2.15.0 works fine for many users, – Dirk Eddelbuettel May 22 '12 at 14:07