18

I have consulted existing entries on SO related to my specific issue, but still could not resolve it.

I am trying to do this with my machine at work, where I have limited admin rights, but I can run Rtools.exe, so I installed it.

My setup for R is:

 platform       x86_64-w64-mingw32          
 arch           x86_64                      
 os             mingw32                     
 system         x86_64, mingw32             
 version.string R version 3.3.0 (2016-05-03)

I am RStudion Version 0.99.902. I installed Rtools version 3.3.0.1959.

All of R, Rstudio, and Rtools are installed in C:/WORK/, which is where I have some limited admin rights.

In my system ENV variable, I have set up:

 C:\\WORK\\Rtools\\bin; C:\\WORK\\Rtools\\gcc-  4.6.3\\bin; C:\\WORK\\R-3.3.0\\bin\\x64;" 

When I run

 system('where make')

I get

 C:\WORK\Rtools\bin\make.exe

When I run

 system('g++ -v')

I get:

 Using built-in specs.
 COLLECT_GCC=C:\WORK\Rtools\GCC-46~1.3\bin\G__~1.EXE
 COLLECT_LTO_WRAPPER=c:/WORK/rtools/gcc-46~1.3/bin/../libexec/gcc/i686-w64-   mingw32/4.6.3/lto-wrapper.exe
 Target: i686-w64-mingw32
 Configured with: /data/gannet/ripley/Sources/mingw-test3/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --prefix=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --with-gmp=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpfr=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpc=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --disable-shared --enable-static --enable-targets=all --enable-languages=c,c++,fortran --enable-libgomp --enable-sjlj-exceptions --enable-fully-dynamic-string --disable-nls --disable-werror --enable-checking=release --disable-win32-registry --disable-rpath --disable-werror CFLAGS='-O2 -mtune=core2 -fomit-frame-pointer' LDFLAGS=
 Thread model: win32
 gcc version 4.6.3 20111208 (prerelease) (GCC) 

When I compile, I get this error:

 Error in compileCode(f, code, language = language, verbose = verbose) : 
 Compilation ERROR, function(s)/method(s) not created!
 c:/Rtools/mingw_64/bin/g++: not found

My question is: why is R still looking for g++ in

 c:/Rtools/mingw_64/bin/g++

Didn't I already set R to look for it in

 C:/WORK/Rtools? 

Even when I manually added

 c:/WORK/Rtools/mingw_64/bin/g++

in the ENV variable, I still got the same error. (I cannot make Rtools folder in C:/ due to admin rights.)

Has anyone run into this specific issue?

DavidH
  • 619
  • 2
  • 8
  • 15
  • Sys.getenv()['PATH'] gives `C:\WORK\R-3.3.0\bin\x64; C:\WORK\Rtools\bin; C:\WORK\Rtools\mingw_64\bin; C:\WORK\Rtools\bin; C:\WORK\Rtools\mingw_32\bin; C:\WORK\R-3.3.0\bin\x64; C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\Program Files (x86)\Microsoft Office\Office14; C:\WINDOWS\System32\WindowsPowerShell\v1.0\; Sys.getenv()['PATH'] C:\APPS\Global\dev_tools;C:\Program Files (x86)\Enterprise Vault\EVClient\; C:\WORK\TortoiseSVN\bin; C:\WORK\Rtools\bin; C:\WORK\Rtools\mingw_64\bin; C:\WORK\R-3.3.0\bin\x64` – DavidH Aug 23 '16 at 15:40

5 Answers5

22

The path c:/Rtools/mingw_64/bin/ is hard-coded into the file Makeconflocated somewhere in the R installation (in my case C:\Progs\R\R-3.4.1\etc\x64), as the value of the variable BINPREF.

The easiest thing to do is to change this path to your path C:/WORK/Rtools/bin (in my case was C:/Progs/RTools/3.4/mingw_64/bin/). That worked for me in a fresh installation of R-3.4.1 and Rtools3.4, and a minimal example.

Linus Ker
  • 221
  • 2
  • 4
  • 2
    Modifying `Makeconf` file should be included as a step in updating Rtools – user3226167 Dec 20 '17 at 09:14
  • 1
    Especially since it is installed in `RBuildTools` directory by default. Thank you! – Zelazny7 Apr 03 '18 at 14:31
  • Might be worth noting that if you can't edit `Makeconf`, you can override `BINPREF` using a `Makevars` file in your home directory. See https://stackoverflow.com/a/56525698/1714 – Hobo Feb 26 '21 at 05:26
4

What is happening is the need to be on RTools 34 and NOT 33 for R 3.3.x.

Remove the rtools install and then follow the guide here:

http://thecoatlessprofessor.com/programming/rcpp/install-rtools-for-rcpp/

@David, you need to remove all instances of C:\WORK\Rtools\<something> and any duplicates (e.g. C:\WORK\R-3.3.0\bin\x64 appears twice.) Then add:

c:\WORK\Rtools\bin; c:\WORK\Rtools\mingw_32\bin;

coatless
  • 20,011
  • 13
  • 69
  • 84
  • The page at https://cran.r-project.org/bin/windows/Rtools/ mentions Rtools3.3 to R 3.2.* and R 3.3.*, and Rtools3.4 for R 3.3.* and up, implying a choice. So OP may just have a `PATH` issue? – Dirk Eddelbuettel Aug 23 '16 at 10:22
  • I uninstalled Rtools33 and installed Rtools34. I still got the same error message: "Compilation ERROR, function(s)/method(s) not created! c:/Rtools/mingw_64/bin/g++: not found". I still can't get R to look for "Rtools/mingw_64/bin" in the place I installed even though I added the path in the ENV variable's PATH. – DavidH Aug 23 '16 at 13:26
  • Please add the output from the following to your post above: `Sys.getenv()['PATH']` – coatless Aug 23 '16 at 14:05
  • @DirkEddelbuettel , I've had better luck on Windows builds associating R with the latest RTools. You are correct in this case that it is definitely a path issue. – coatless Aug 23 '16 at 14:06
  • I am with you that the newest is generally a safe bet; I simply wanted to state that Rtools3.4 was not the only game in town. And yes, I too was bitten by the `PATH` just last week updating a vm. – Dirk Eddelbuettel Aug 23 '16 at 14:08
  • C:\WORK\R-3.3.0\bin\x64; C:\WORK\Rtools\bin; C:\WORK\Rtools\mingw_64\bin; C:\WORK\Rtools\bin; C:\WORK\Rtools\mingw_32\bin; C:\WORK\R-3.3.0\bin\x64; C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\Program Files (x86)\Microsoft Office\Office14; C:\WINDOWS\System32\WindowsPowerShell\v1.0\; C:\APPS\Global\dev_tools;C:\Program Files (x86)\Enterprise Vault\EVClient\; C:\Program Files\Microsoft Office15\root\office15; C:\WORK\TortoiseSVN\bin; C:\WORK\Rtools\bin; C:\WORK\Rtools\mingw_64\bin; C:\WORK\R-3.3.0\bin\x64 (There are some repeats, I realize) Thx! – DavidH Aug 23 '16 at 14:21
  • @David see above. – coatless Aug 24 '16 at 02:42
  • 1
    The newest version of Rtools actually constructs paths to the gcc / g++ compilers on demand; you now only need `Rtools\bin` on the `PATH`. When `make.exe` is called, R will then effectively tell it to look for `gcc` at `..\mingw_64\bin\gcc.exe` (assuming 64bit Windows). Note that the directories `Rtools\mingw_32` and `Rtools\mingw_64` should be populated by default by the new Rtools installers. – Kevin Ushey Aug 24 '16 at 22:56
  • @KevinUshey Are you sure about this? Using the latest version of Rtools (version 3.4.0.1964), if I only put, e.g., `C:\R\devel34\Rtools\bin` (but not `C:\R\devel34\Rtools\mingw_64\bin`) on my `PATH`, running `Rcpp::evalCpp("2+2")` fails with a message that `c:/Rtools/mingw_64/bin/g++: not found`. (Of course, if I've also got another installation of Rtools with `C:\Rtools\mingw_64\bin\g++`, it works, and the failure to find `C:\R\Rdevel34\mingw_64\bin` is masked...) – Josh O'Brien Sep 29 '17 at 17:17
  • Hmm. It actually works for me with the `PATH` left completely unset, so maybe R checks some default locations for Rtools? (I notice you don't have Rtools installed in the default location) – Kevin Ushey Sep 29 '17 at 17:51
  • @KevinUshey Exactly. In other words, Rtools doesn't search for a `gcc.exe` in a path relative to the supplied `Rtools\bin`. Instead, it in effect appends the paths `C:\Rtools\bin` and `C:\Rtools\mingw_64\bin` to `PATH`, and will use the executables in those directories (if they exist) unless those executables are found early on along the search path. So as @coatless indicates, you'll need to add two directories to your `PATH` if you want to use an Rtools distribution installed elsewhere than the default location. – Josh O'Brien Sep 29 '17 at 22:10
2

I was hitting the same issue on Windows 10 with RStudio 1.3+ and RTools 4.0. After installing RTools and trying to install another package (that needed RTools) it kept throwing the error

c:/rtools40/mingw32/bin/g++: No such file or directory

It kept picking up the wrong path of the RTools installation on windows. After restarting RStudio it picked up the right path:

C:\RBuildTools\4.0\mingw32\bin

Abhimanu Kumar
  • 1,751
  • 18
  • 20
1

A plausible and easy way to do this is to choose "Full installation to build 32 or 64 bit" in the following promp.enter image description here

glennsl
  • 28,186
  • 12
  • 57
  • 75
H.Lee
  • 11
  • 2
0

I solved like this: Just copy the files needed in the path where it is looking for. ( my case, in C:\rtools40\mingw64\ copied the bin directory into the path he search for and worked !)