Error when compiling RInside examples on Windows

142 views Asked by At

I have an issue compiling the RInside examples on Windows.

In Rstudio, running

sourceCpp("C:/Users/Admin/Documents/R/win-library/3.5/RInside/examples/standard/rinside_sample0.cpp")

gives

fatal error: RInside.h: No such file or directory

From the command promt, running

cd C:\Users\Admin\Documents\R\win-library\3.5\RInside\examples\standard
make -f Makefile.win rinside_sample0

gives

Error in loadNamespace(name) : aucun package nommé 'Rcpp' n'est trouvé
Error in loadNamespace(name) : aucun package nommé 'RInside' n'est trouvé

Apparently these packages are not found, so I tried the following:

  1. Ran this from the command line set R_HOME=C:\Program Files\R\R-3.5.2
  2. Checked that Rtools and R dirs are present in the path
  3. Modified the Makefile.win like so:

R_LIBS_USER := "C:/Users/Admin/Documents/R/win-library/3.5"

R_ARCH := --arch x64

But still getting the same errors. Any help? Thanks


EDIT: this answer might provide a solution by including this line of code somewhere

export R_LIBS_SITE=c:/R/site-library

However I don't know where to include it.


EDIT2 I have tried to reinstall Rcpp and RInside in both library locations (by running RStudio as admin)

remove.packages("Rcpp", lib = .libPaths())
remove.packages("RInside", lib = .libPaths())
install.packages("RInside", lib = .libPaths())
install.packages("Rcpp", lib = .libPaths())
library("RInside")
library("Rcpp")

In RStudio I still have the same error using sourceCpp, however, using the comand prompt and make approach I do get a different error:

make -f Makefile.win rinside_sample0 
g++.exe: error: Files/R/R-3.5.2/library/RInside/include: No such file or directory

I suppose the space in the path is the problem " Files..." will try to reinstall R in a non-spaced path

1

There are 1 answers

0
gaut On

Reinstalling R in a path without spaces, installing the latest packages, and setting R_HOME environment variable to the new installation folder C:\R\R-3.5.2 solved the problem.

remove.packages("Rcpp", lib = .libPaths())
remove.packages("RInside", lib = .libPaths())
install.packages("RInside", lib = .libPaths())
install.packages("Rcpp", lib = .libPaths())
library("RInside")
library("Rcpp")