tags
tags

Reputation: 4060

Message error 'C:/Program' not found with Rcpp

I'm running a 64-bit Windows 7 platform.

I have added to my installed programs/libraries:

I tried out a snippet found here

## now with Rcpp and C++
library(inline)
# and define our version in C++
src <- "int n = as<int>(ns);
double x = as<double>(xs);
for (int i=0; i<n; i++) x=1/(1+x);
return wrap(x); "
l <- cxxfunction(signature(ns="integer", xs="numeric"),
body=src, plugin="Rcpp")

But that doesn't work (That is not a surprise to be honest as I even didn't specified eg the location of Rtools). I get the following error message:

Error in system(cmd, intern = !verbose) : 'C:/Program' not found

I'm not sure of what that means. And, I have been stuck there for a couple of hours now. Can anyone help me a bit, please?

Upvotes: 5

Views: 4007

Answers (3)

stevec
stevec

Reputation: 52468

I was seeing the same error on windows when running this

system("C:/Program Files/...", intern=TRUE)

it was because there's a space in the path (i.e. in Program Files).

This is what solved for me.

Instead of system(), use system2().

system2("C:/Program Files/...")

And that will work.

Upvotes: 0

Dirk is no longer here
Dirk is no longer here

Reputation: 368399

The R on Windows FAQ says in Question 2.2:

If you want to be able to build packages from sources, we recommend that you choose an installation path not containing spaces.

Also see Question 2.16 of that FAQ. I am fairly certain that we also make that point repeatedly in the Rcpp documentation.

Now, if you forgo the inline package, and try working in RStudio, then you might get around this (as there are more efforts to protect the $PATH with spaces).

But in short, I would reinstall R into, say C:\R\R-$version as it is the only way to get default behaviour on all examples. And we have lots of them. It's worth reinstalling.

Upvotes: 3

tags
tags

Reputation: 4060

Following nograpes suggestion I get:

>> setting environment variables: 
PKG_LIBS =  C:/Users/ (...) /DOCUME~1/R/WIN-LI~1/3.0/Rcpp/lib/x64/libRcpp.a

>> LinkingTo : Rcpp
CLINK_CPPFLAGS =  -I"C:/Users/  (...)  /Documents/R/win-library/3.0/Rcpp/include" 

>> 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 file47844fc6c7a( SEXP ns, SEXP xs) ;
24 : }
25 : 
26 : // definition
27 : 
28 : SEXP file47844fc6c7a( SEXP ns, SEXP xs ){
29 : BEGIN_RCPP
30 : int n = as<int>(ns);
31 : double x = as<double>(xs);
32 : for (int i=0; i<n; i++) x=1/(1+x);
33 : return wrap(x); 
34 : END_RCPP
35 : }
36 : 
37 : 

Compilation argument:
 C:/Program Files/R-3.0.1/bin/x64/R CMD SHLIB file47844fc6c7a.cpp 2>         file47844fc6c7a.cpp.err.txt 
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'file47844fc6c7a.cpp.err.txt': No such file or directory

But, I admit that doesn't help me that much.

Upvotes: 0

Related Questions