Installation of Rstan


#1

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\\

#2

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.


#3

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