My Problem
I installed Rtools
and added the path to my PATH
variable:
mPath <- strsplit(Sys.getenv("PATH"), ";")[[1]]
mPath[grep("Rtools", mPath)]
# [1] "C:\\Temp\\Rtools\\bin" "C:\\Temp\\Rtools\\gcc-4.6.3\\bin"
# [3] "C:\\Temp\\Rtools\\gcc-4.6.3\\bin32" "C:\\Temp\\Rtools\\mingw_32\\bin"
(So you can see it is not installed directly at c:\Rtools
)
When I try to run a simple Rcpp
snippet, I get the following error:
library(Rcpp)
evalCpp("1+1")
[...]
c:/Rtools/mingw_32/bin/g++: not found
So basically Rcpp
is looking in C:/Rtools
ignoring my PATH
variable.
Workaround
If I run
library(installr)
install.Rtools()
Loading required namespace: devtools
No need to install Rtools - You've got the relevant version of Rtools installed
and then run evalRcpp("1+1")
again, everything works as expected.
My Question
Why does it not work right away? How do I tell Rcpp
to look in the right folder? How does install.Rtools
manage to convince Rcpp
to look into the right folder? How can I achieve that without the workaround?