Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

rcpp

I'm just trying to get started with Rcpp and I keep running into this error no matter what I do.

> library("Rcpp")
> evalCpp("2 + 2")
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG   -I"//ad.uws.edu.au/dfshare/HomesBLK90946112/My Documents/R/win-library/4.0/Rcpp/include" -I"C:/Users/90946112/AppData/Local/Temp/Rtmp0Q7m7J/sourceCpp-x86_64-w64-mingw32-1.0.5"        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c file45bc2c9438a5.cpp -o file45bc2c9438a5.o
file45bc2c9438a5.cpp:1:10: fatal error: Rcpp.h: No such file or directory
 #include <Rcpp.h>
          ^~~~~~~~
compilation terminated.
make: *** [C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf:229: file45bc2c9438a5.o] Error 1
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir,  : 
  Error 1 occurred building shared library.

To check that everything is set up correctly, I have run the following checks:

> find_rtools()
[1] TRUE
> find.package('Rcpp')
[1] "\\\\ad.uws.edu.au/dfshare/HomesBLK$/90946112/My Documents/R/win-library/4.0/Rcpp"

and

> find_rtools()
[1] TRUE
> find.package('Rcpp')
[1] "\\\\ad.uws.edu.au/dfshare/HomesBLK$/90946112/My Documents/R/win-library/4.0/Rcpp"
> Sys.getenv("PATH")
[1] "C:\\rtools40\\usr\\bin;C:\\Program Files\\R\\R-4.0.2\\bin\\x64;C:\\Rtools\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Users\\90946112\\AppData\\Local\\Microsoft\\WindowsApps;"
> has_devel()
Your system is ready to build packages!

I've seen so many questions on here for similar problems but none for Rtools40- which has a different file path- and none have helped. I have tried using an older version of R and Rtools. I've also uninstalled and reinstalled both.

Please help!

like image 540
katefull06 Avatar asked Nov 16 '22 05:11

katefull06


1 Answers

Sorted! Thanks to @dratenik for the help.

I uninstalled the Rcpp package, ran RStudio as administrator, reinstalled Rcpp in a library that had no special characters, and it runs fine now.

like image 144
katefull06 Avatar answered Jan 09 '23 14:01

katefull06