*************************************************************************************************************
---------------------------------------------------------------------------------------------------------------
> # Lines of code to tun before installing rstan:
>
> # First set:
> dotR <- file.path(Sys.getenv("HOME"), ".R")
> if (!file.exists(dotR)) dir.create(dotR)
> M <- file.path(dotR, "Makevars")
> if (!file.exists(M)) file.create(M)
> cat("\nCXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function",
+ file = M, sep = "\n", append = TRUE)
>
> # Second set:
> cat('Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")',
+ file = file.path(Sys.getenv("HOME"), ".Rprofile"),
+ sep = "\n", append = TRUE)
>
> # Test set:
> cat(readLines(M), sep = "\n")
CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function
CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function
> cat(M)
C:/Users/Zef/Documents/.R/Makevars
>
>
> # Install RStan:
> install.packages("rstan", dependencies = TRUE)
Installing package into ‘C:/Users/Zef/R-Library’
(as ‘lib’ is unspecified)
Content type 'application/zip' length 3251255 bytes (3.1 MB)
downloaded 3.1 MB
package ‘rstan’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Zef\AppData\Local\Temp\RtmpsfBEPb\downloaded_packages
>
> # If above line fails, do these 3 lines:
> # # omit the "s" if you cannot handle https downloads
> # install.packages("rstan", dependencies = TRUE)
>
> # If all else fails, you can try to install rstan from source via
> # install.packages("rstan", type = "source")
>
---------------------------------------------------------------------------------------------------------------
library(inline)
library(rstan)
# As the startup message says, if you are using rstan locally on a multicore
# machine and have plenty of RAM to estimate your model in parallel, at this
# point execute the 2 next lines of code:
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
# Then execute:
example("cxxfunction", package = "inline", run.dontrun = TRUE)
And here is what I get:
cxxfnc> # default plugin
cxxfnc> fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
cxxfnc+ return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
cxxfnc+ ' )
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-33~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.0/share/make/winshlib.mk" -f "C:/Users/Zef/Documents/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file136c30e779ff.dll" WIN=64 TCLBIN=64 OBJECTS="file136c30e779ff.o"' had status 127
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern "C" {
13: SEXP file136c30e779ff( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file136c30e779ff( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning("your C++ program does not return anything");
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! Warning message:
running command 'make -f "C:/PROGRA~1/R/R-33~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.0/share/make/winshlib.mk" -f "C:/Users/Zef/Documents/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file136c30e779ff.dll" WIN=64 TCLBIN=64 OBJECTS="file136c30e779ff.o"' had status 127
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-33~1.0/bin/x64/R CMD SHLIB file136c30e779ff.cpp 2> file136c30e779ff.cpp.err.txt' had status 1
>
All the R packages have been updated.
I also add two pathways (permanently) to my windows path environment variable: C:\RTools\bin;C:\RTools\gcc-4.6.3\bin
But no success.
Any idea ???