When updating to RStudio 1.2, I had to switch from using 32-bit to a 64-bit version of R. However, the R C compiler command is still looking to a 32-bit version of MinGW, which means that I can't compile packages for a 64-bit installation.
I've tried uninstalling and reinstalling RTools 3.5 and R 3.6.0, and the PATH
and BINPREF
environment variables point to the appropriate 64-bit folders. Nevertheless, R is still looking for a 32-bit C compiler when compiling packages that contain C source code: R CMD config CC
returns C:/Rtools/mingw_32/bin/gcc
, but I can't work out how to change this to mingw_64
.
As a result, when I run devtools::install()
(or check
, load_all
etc), I'm confronted with an error:
* installing *source* package 'MYPACKAGE' ...
** using staged installation
** libs
sh: line 6: C:/Rtools/mingw_32/bin/nm: No such file or directory
C:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o MYPACKAGE.dll tmp.def [...] -LC:/PROGRA~1/R/R-36~1.0/bin/x64 -lR
sh: line 8: C:/Rtools/mingw_32/bin/g++: No such file or directory
no DLL was created
ERROR: compilation failed for package 'MYPACKAGE'
RStudio throws up a dialog box offering to install RTools, but proceeding with the installation doesn't help: the CC path is unchanged.
The value of BINPREF
specified in C:\Program files\R\R-3.6.0\etc\x64\Makeconf
was being overwritten by a different value that I'd previously specified (by hand, as /mingw_32/
rather than the preferable /mingw_$(WIN)/
) in C:\Users\MYUSERNAME\Documents\.R\Makevars
, which of course survived the uninstallation of R. Updating this file to point to the 64-bit path resolved the issue.
Thanks to duckmayr for leading me to the answer.