The compiler wants to include R.h header file. These header files come installed with R, so obviously, the include is in the R installation dir.
But while trying to install a package, the compiler is looking at the wrong paths (though I added the path in my env vars):
g++ -std=gnu++17 -I"/include" -DNDEBUG -I'~/R/win-library/3.6/sp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c dummy.cc -o dummy.o
gcc -I"/include" -DNDEBUG -I'~/R/win-library/3.6/sp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c init.c -o init.o
init.c:1:10: fatal error: R.h: No such file or directory
1 | #include <R.h>
| ^~~~~
compilation terminated.
Is there any way to make the compiler look at the include path specified in my env vars?
/s/ is a dependency for rgeos package:
install.packages("~/R/win-library/3.6/rgeos_0.6-4.tar.gz", repos = NULL, type = "source")
I had to transfer R headers from R install dir to /sp/ so the compiler can find them. I shouldn't have to do that...
Turned out it was indeed a cluttered environment variables and installation system. Here's what I have done and hopefully it helps someone:
C:\rtools43\usr\bin
(instead of just C:\rtools43
add:
and save.
Reboot your system. If RTOOLS43_HOME entry doesn't show on the environment variables, just add it explicitly:
Note, above entry is NOT to be put in the path. I added it to both system and user vars just in case the latter doesn't have some permissions.
On Rstudio, under Tools/Install Packages/Install to Library:
should have as default entry the value of R_LIBS_USER from above.
Finally, the output of
.libPaths()should only include reachable and active/used paths for a)libraries install dir and b)R dir.Above paths are specific to Windows 10. Yours will be dependent on your system.
If you did EVERYTHING as suggested here. You can now run a successful install such as:
Without the compiler breaking on ya. Good luck and don't forget to thumb UP this answer if you found it useful. So it will be recommended to others. Thanks in advance!