Error from cppFunction(Rcpp) under R 15.2 Windows

2019-08-04 08:41发布

问题:

This question already has an answer here:

  • How to get Rcpp to work in R on a Windows XP platform? 3 answers

When I've called :

cppFunction('
  int add(int x, int y, int z) {
    int sum = x + y + z;
    return sum;
  }'
)

Error with below message occured, anyone have meet similar problem ? Any clues how to interprete this message ?

g

    ++  -I"D:/PROGRA~1/R/R-215~1.2/include" -DNDEBUG     -I"D:/Program Files/R/R-2.15.2/library/Rcpp/include"      -O2 -Wall  -mtune=core2 -c filed946a0620c7.cpp -o filed946a0620c7.o g++ -shared -s -static-libgcc -o sourceCpp_70998.dll tmp.def filed946a0620c7.o D:/Program Files/R/R-2.15.2/library/Rcpp/lib/i386/libRcpp.a -LD:/PROGRA~1/R/R-215~1.2/bin/i386 -lR g++.exe: error: D:/Program: No such file or directory g++.exe: error: Files/R/R-2.15.2/library/Rcpp/lib/i386/libRcpp.a: No such file or directory 
    Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput,  : 
  Error occurred building shared library.

回答1:

You installed R in a path with spaces. Which breaks things.

R defaults to this even though the R-on-Windows FAQ says not to do this.

The next Rcpp version has a defense against this. Until then, move your R installation.

Oh, and I answered this very question probably three times already on SO alone...