14

I am trying to install an R package which contains some C code under Windows. I have R 3.3.0 installed and also Rtools 3.3.0 installed on my computer's D: disk.

And d:\Rtools\bin and d:\Rtools\mingw_64\bin are all in PATH. I checked gcc command under command window, and it is working.

But when I am installing the package, it always trying to use c:/Rtools/mingw_64/bin/gcc, which should be in d: disk, then it gives c:/Rtools/mingw_64/bin/gcc: not found error.

Can anyone help on this issue?

Thanks!

Andrie
  • 176,377
  • 47
  • 447
  • 496
Zhe Liu
  • 451
  • 1
  • 3
  • 7
  • Did you try it with `devtools` and/or RStudio? Perhaps you can try it with this example, if your PATH is right: http://stackoverflow.com/questions/19885381/rtools-not-being-detected-by-r – J_F Jun 09 '16 at 19:40
  • 3
    Actually, this only happens to R 3.3.0, for other version of R, e.g.3.2.3, they can automatically find the right path of gcc, as long as it is in PATH. So I am not sure whether this is a bug of R 3.3.0. – Zhe Liu Jun 09 '16 at 20:12

2 Answers2

21

OK, I sent an email to the R-package-devel group regarding to this issue. And the following is the reply, and it does work!

Please adapt your BINPREF variable in R/etc/$Arch/Makeconf files appropriately to point to the coresponding compiler for each architecture - this is new with the new toolchain we use with R >= 3.3.0.

Zhe Liu
  • 451
  • 1
  • 3
  • 7
  • 1
    Did they tell you as well why this was introduced and why at this place? In my case I cannot alter this file as I do not have admin privileges. That is a rather stupid feature... – Benjamin Hofner Nov 21 '16 at 15:49
  • Please also not that paths need to be given as DOS paths, i.e. instead of `C:\Program Files` one needs to use `C:\PROGRA~1` and instead of `C:\Program Files (x86)` one needs to use `C:\PROGRA~2`. – Benjamin Hofner Nov 21 '16 at 16:14
  • For details on how to set the BINPREF variable see my answer here: http://stackoverflow.com/a/44035904/4468078 – R Yoda May 17 '17 at 22:49
0

If you don't want to edit the Makefile directly (as of R 3.6.3 at least), you can set BINPREF as an environment variable pointing to the appropiate mingw_{32,64}/bin/ path

Couple of gotcha's on Windows to note:

  • Need to use forward slahes in the path (and so can't use any environment variables like %LocalAppData% in there)
  • Trailing forward slash after bin
rwb
  • 4,309
  • 8
  • 36
  • 59