Getting an error while installing SP package

I am getting the below error while trying to install 'SP' package in R Studio. Can someone please help me with this?

  • installing source package 'sp' ...
    ** package 'sp' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    gcc -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c Rcentroid.c -o Rcentroid.o
    process_begin: CreateProcess(NULL, gcc -IC:/PROGRA~1/R/R-42~1.2/include -DNDEBUG -Ic:/rtools42/x86_64-w64-mingw32.static.posix/include -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c Rcentroid.c -o Rcentroid.o, ...) failed.
    make (e=2): The system cannot find the file specified.
    make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:253: Rcentroid.o] Error 2
    ERROR: compilation failed for package 'sp'
  • removing 'C:/Users/AppData/Local/R/win-library/4.2/sp'
    Warning in install.packages :
    installation of package ‘C:/users/downloads/sp_1.6-0.tar.gz’ had non-zero exit status

This error message suggests that the system cannot find the gcc compiler, which is needed to build the 'sp' package from source. It is also possible that there is an issue with the path to the compiler specified in the R configuration file (Makeconf).

One solution would be to install the package from a pre-compiled binary instead of building from source. This can be done by using the command install.packages("sp", type = "binary").

Another solution is to check that the gcc compiler is installed on your system and that the path to the compiler is correctly specified in the R configuration file. You can check the path by running the command Sys.getenv("PATH") in R and make sure that the path to the gcc compiler is included. If it is not, you can add the path to the compiler by running Sys.setenv(PATH = paste(Sys.getenv("PATH"), "path/to/gcc", sep = ":")).

If the problem persist, I suggest you to check the version of R, RStudio and the version of gcc. Make sure they are compatible with each other and try again.

Thank you so much! It worked!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.