1

I am trying to install an r-package via github via devtools::install_github('package_name')

I get the following error: "sh: g++ not found" and "ERROR: compilation failed for package 'package_name' "

Question: What do I need to do in order to have/find g++?

=========================================================

Extra information:

  • Windows 8.1 OS
  • R version 4.1.0
  • devtools version 2.4.2
  • rtools 40 installed (find_rtools() -> TRUE)
Riktros
  • 21
  • 1
  • Take a look at answers here: https://stackoverflow.com/questions/39090983/rcpp-rtools-installed-but-error-message-g-not-found – iago Jul 28 '21 at 16:10
  • I came across this solution but I don't think this helps me. I find a 'g++.exe' file at `\rtools40\mingw64\bin` which is the default in makeconfig file. – Riktros Jul 28 '21 at 16:24
  • (1) Try moving (at least temporarily) `C:\RTools40` to `C:\RTools` to see if that fixes the issue ... I've seen some packages with hard-coded assumptions about compiler locations. (2) It would likely be easier to help you with this if we can look at the specific package itself: perhaps its makefile(s) is wrong or out-of-date or something else. (3) FYI, for me, `Sys.which("g++")` returns nothing (which is fine), but installing compilable packages (from github) works fine. For me, it's `C:\Rtools\mingw_64\bin\g++.exe` (and `mingw_32`). – r2evans Jul 28 '21 at 16:33
  • Thank you for your comment r2evans. I have managed to temporarily solve the problem by changing the PATH variable in r to include the directory where g++ is. In other words, running `Sys.setenv(PATH = paste("C:\\rtools40\\mingw64\\bin", Sys.getenv("PATH"), sep=";")` I did not expect it to solve the problem, since `"C:\\rtools40\\mingw64\\bin"` was already in the PATH variable, it just was not the first one. I don't know enough about R to know why this solved the problem, but it did. – Riktros Jul 28 '21 at 16:37
  • My guess is that this is not an R thing but instead related to _that_ package. Glad it worked, even has a band-aid fix. – r2evans Jul 28 '21 at 17:16

0 Answers0