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

心已入冬 提交于 2019-12-19 10:14:24

问题


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

I have added to my installed programs/libraries:

  • Rtools

  • R (software)

  • Rcpp (R package)

  • inline (R package)

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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/18944594/message-error-c-program-not-found-with-rcpp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!