Installation of Rstan

I have Rstan installed on Linux, but wanted to install it on Windows today. I followed the instructions found here.

All went well until this line

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
	return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
' )
fx( 2L, 5 )

which produced the following

running command 'C:/PROGRA~1/R/R-34~1.3/bin/x64/R CMD SHLIB file1920535d1a83.cpp 2> file1920535d1a83.cpp.err.txt' had status 1

C:/RBuildTools/mingw_64/bin/g++: not found
make: *** [file1920535d1a83.o] Error 127

Warning message:
running command 'make -f "C:/PROGRA~1/R/R-34~1.3/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-34~1.3/share/make/winshlib.mk" -f "C:/Users/ahallam/Documents/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file1920535d1a83.dll" WIN=64 TCLBIN=64 OBJECTS="file1920535d1a83.o"' had status 2 

ERROR(s) during compilation: source code errors or compiler configuration errors!

As the error states C:/RBuildTools/mingw_64/bin/g++: not found I produced the following

> system('g++ -v')

gcc version 4.9.3 (i686-posix-dwarf, Built by MinGW-W64 project) 

then I wondered about make so I produced the following

> system('where make')

C:\Rtools\bin\make.exe

It seems like I have all of the right parts, but maybe not in the right places? I am not sure. Here is my relevant PATH

> Sys.getenv('PATH')

"C:\\Rtools\\bin;C:\\Program Files\\R\\R-3.4.3\\bin\\x64;c:\\Rtools\\bin;c:\\Rtools\\mingw_32\\bin;C:\\Program Files\\R\\R-3.4.3\\bin\\

The thing that got my intereset was that make searches for g++ in C:/RBuildTools/ but your PATH seems to indicate the it is installed in C:/Rtools.

Following

this might be related to a misconfiguration in your Makeconf file.

1 Like

Thanks @martinmodrak

The solution that worked for me was as follows

  1. Delete “c:\Rtools\mingw_32\bin” in the windows PATH
  2. Restart R

Hi all,

I install Rtool and run the code Sys.getenv(“PATH”) and the output is
[1] “C:\Program Files\R\R-3.5.0\bin\x64;c:\Rtools\bin;c:\Rtools\mingw_32\bin;c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;c:\Rtools\bin;c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;c:\Rtools\bin;c:\Rtools\bin;C:\Program Files\Microsoft MPI\Bin\;c:\Rtools\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\ndowsPowerShell\v1.0\;C:\Program Files\PuTTY\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Users\Nhat Le Thanh Hoang\AppData\Local\Microsoft\WindowsApps;”

It started with “C:\Program Files\R\R-3.5.0\bin\x64” not with “C:\Rtools\bin;”.Does it mean I didn’t install Rtools correctly? How do I fix this?

Thanks,
Nhat