4
votes

I've been trying to work with Rcpp in R 2.14.2 on a Windows XP platform. As far as I can tell, I followed all of the recommended steps for getting Rcpp to work:

  1. I installed R in a directory called C:\R\R-2.14.2;
  2. I installed the latest version of Rtools in the directory C:\R\Rtools;
  3. I set the environment PATH to the following (in this exact same order):

C:\R\Rtools\bin;C:\R\Rtools\gcc-4.6.3\bin;
C:\R\R-2.14.2\bin\i386;C:\WINDOWS;C:\WINDOWS\system32

Despite all of this, when I tried to run a test example in R to see if Rcpp works, I got an error message. Here is the test example:

library(Rcpp)
library(inline)

body <- '
NumericVector xx(x);
return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));'

add <- cxxfunction(signature(x = "numeric"), body, plugin = "Rcpp")

x <- 1
y <- 2
res <- add(c(x, y))
res

Here is the rather long error message produced by R as a result of trying to execute the above R code. Can anyone tell me what it is that I am doing wrong and what else I need to do to make sure that Rcpp works?

cygwin warning:
MS-DOS style path detected: C:/R/R-214~1.2/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-214~1.2/etc/i386/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
g++.exe: error: C:/Documents: No such file or directory
g++.exe: error: and: No such file or directory
g++.exe: error: Settings/dv6110ca/My: No such file or directory
g++.exe: error: Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a: No such file  
or directory

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 file684203c3ec2( SEXP x) ;
24: }
25: 
26: // definition
27: 
28: SEXP file684203c3ec2( SEXP x ){
29: BEGIN_RCPP
30: 
31: NumericVector xx(x);
32: return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));
33: END_RCPP
34: }
35: 
36: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
Compilation ERROR, function(s)/method(s) not created! cygwin warning:
MS-DOS style path detected: C:/R/R-214~1.2/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-214~1.2/etc/i386/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
g++.exe: error: C:/Documents: No such file or directory
g++.exe: error: and: No such file or directory
g++.exe: error: Settings/dv6110ca/My: No such file or directory
g++.exe: error: Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a: No such file or  
directory
3

3 Answers

4
votes

Do not install R in a directory containing a space in the path name. That recommendation is, as I recall, in the 'R for Windows FAQ'.

My personally preference is always c:\opt\R-current\ instead of the versioned default path.

3
votes

The error is explained in the last 5 lines of the message you posted:

g++.exe: error: C:/Documents: No such file or directory
g++.exe: error: and: No such file or directory
g++.exe: error: Settings/dv6110ca/My: No such file or directory
g++.exe: error: Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a: No such file or  
directory

g++.exe is looking for a file called libRcpp.a but the file is in a folder with spaces in its name, in particular in your computer the file is in this folder:

C:/Documents and Settings/dv6110ca/My Documents/R/win-library/2.14/Rcpp/lib/i386/libRcpp.a

and the path to the folder contains 3 spaces (between Documents and and, between and and Settings, between My and Documents). In some way your compiler/linker does not like that spaces.

2
votes

I was having the same problem setting up Rcpp. It looks like you uninstalled R and then re-installed it to create a set up compatible with Rcpp. When you do this, R will install packages in the same folder as the previous installs. After uninstalling R, make sure that you delete the folder that holds the packages. On my windows 7 machine, this was folder was located in C:/Users/Chandler/R. Delete this folder; then re-install R. Make sure that new packages are installed in your new R folder, e.g. C:\R\R-2.14.2\library. This should eliminate the problem with spaces in folder locations that Dirk mentioned above.

Also, make sure the path is the same as the example in the "R Installation and Administration" manual appendix D. It will easiest to follow this manual if you are using the most current version of R instead of 2.14.2

Note: I still get the cygwin warning even though Rcpp works.