Intallation Windows 10: toolchain not working


#1

Operating System: Windows 10
Interface Version:
Output of writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”))):
CXXFLAGS=-03 -Wno-unused-variable -Wno-unused-function

CXXFLAGS=-03 -Wno-unused-variable -Wno-unused-function

CXXFLAGS=-03 -Wno-unused-variable -Wno-unused-function

CXXFLAGS=-03 -Wno-unused-variable -Wno-unused-function

CXXFLAGS=-03 -Wno-unused-variable -Wno-unused-function

CXXFLAGS=-03 -Wno-unused-variable -Wno-unused-function
CXXFLAGS=-03 -Wno-unused-variable -Wno-unused-function

Output of devtools::session_info("rstan”):
Session info ---------------------------------------------------------------
setting value
version R version 3.4.2 (2017-09-28)
system x86_64, mingw32
ui RStudio (1.1.423)
language (EN)
collate English_United States.1252
tz America/New_York
date 2018-03-06

Packages -------------------------------------------------------------------
package * version date source
assertthat 0.2.0 2017-04-11 CRAN (R 3.4.0)
BH 1.66.0-1 2018-02-13 CRAN (R 3.4.3)
cli 1.0.0 2017-11-05 CRAN (R 3.4.3)
colorspace 1.3-2 2016-12-14 CRAN (R 3.4.0)
crayon 1.3.4 2017-09-16 CRAN (R 3.4.3)
dichromat 2.0-0 2013-01-24 CRAN (R 3.4.0)
digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
ggplot2 2.2.1 2016-12-30 CRAN (R 3.4.0)
glue 1.2.0 2017-10-29 CRAN (R 3.4.2)
graphics * 3.4.2 2017-09-28 local
grDevices * 3.4.2 2017-09-28 local
grid 3.4.2 2017-09-28 local
gridExtra 2.3 2017-09-09 CRAN (R 3.4.1)
gtable 0.2.0 2016-02-26 CRAN (R 3.4.0)
inline 0.3.14 2015-04-13 CRAN (R 3.4.2)
labeling 0.3 2014-08-23 CRAN (R 3.4.0)
lattice 0.20-35 2017-03-25 CRAN (R 3.4.2)
lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.3)
magrittr 1.5 2014-11-22 CRAN (R 3.4.0)
MASS 7.3-47 2017-02-26 CRAN (R 3.4.2)
Matrix 1.2-11 2017-08-21 CRAN (R 3.4.2)
methods * 3.4.2 2017-09-28 local
munsell 0.4.3 2016-02-13 CRAN (R 3.4.0)
pillar 1.2.1 2018-02-27 CRAN (R 3.4.2)
plyr 1.8.4 2016-06-08 CRAN (R 3.4.0)
R6 2.2.2 2017-06-17 CRAN (R 3.4.3)
RColorBrewer 1.1-2 2014-12-07 CRAN (R 3.4.0)
Rcpp 0.12.15 2018-01-20 CRAN (R 3.4.3)
RcppEigen 0.3.3.4.0 2018-02-07 CRAN (R 3.4.3)
reshape2 1.4.3 2017-12-11 CRAN (R 3.4.3)
rlang 0.2.0 2018-02-20 CRAN (R 3.4.3)
rstan 2.17.3 2018-01-20 CRAN (R 3.4.3)
scales 0.5.0 2017-08-24 CRAN (R 3.4.3)
StanHeaders 2.17.2 2018-01-20 CRAN (R 3.4.3)
stats * 3.4.2 2017-09-28 local
stats4 3.4.2 2017-09-28 local
stringi 1.1.6 2017-11-17 CRAN (R 3.4.2)
stringr 1.3.0 2018-02-19 CRAN (R 3.4.3)
tibble 1.4.2 2018-01-22 CRAN (R 3.4.3)
tools 3.4.2 2017-09-28 local
utf8 1.1.3 2018-01-03 CRAN (R 3.4.3)
utils * 3.4.2 2017-09-28 local
viridisLite 0.3.0 2018-02-01 CRAN (R 3.4.3)

I’m trying to install RStan using the instructions provided here:

But when I try to execute the code in the final verification step:
Verify that your toolchain works by executing the code below in R and checking that it returns the value 10:
fx <- inline::cxxfunction( signature(x = “integer”, y = “numeric” ) , ‘
return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
’ )
fx( 2L, 5 ) # should be 10

And I get the following error:

fx <- inline::cxxfunction( signature(x = “integer”, y = “numeric” ) , ’

  •     return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
    
  • ’ )
    g++.exe: error: unrecognized command line option ‘-03’
    make: *** [file677858939a6.o] Error 1
    Warning message:
    running command ‘make -f “C:/PROGRA~1/R/R-34~1.2/etc/x64/Makeconf” -f “C:/PROGRA~1/R/R-34~1.2/share/make/winshlib.mk” -f “C:/Users/Ashley/Documents/.R/Makevars” SHLIB_LDFLAGS=’(SHLIB_CXXLDFLAGS)' SHLIB_LD='(SHLIB_CXXLD)’ SHLIB=“file677858939a6.dll” WIN=64 TCLBIN=64 OBJECTS=“file677858939a6.o”’ had status 2

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 file677858939a6( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file677858939a6( 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! g++.exe: error: unrecognized command line option ‘-03’
make: *** [file677858939a6.o] Error 1
Warning message:
running command ‘make -f “C:/PROGRA~1/R/R-34~1.2/etc/x64/Makeconf” -f “C:/PROGRA~1/R/R-34~1.2/share/make/winshlib.mk” -f “C:/Users/Ashley/Documents/.R/Makevars” SHLIB_LDFLAGS=’(SHLIB_CXXLDFLAGS)' SHLIB_LD='(SHLIB_CXXLD)’ SHLIB=“file677858939a6.dll” WIN=64 TCLBIN=64 OBJECTS=“file677858939a6.o”’ had status 2
In addition: Warning message:
running command ‘C:/PROGRA~1/R/R-34~1.2/bin/x64/R CMD SHLIB file677858939a6.cpp 2> file677858939a6.cpp.err.txt’ had status 1

Not sure what I did incorrectly. Any help is much appreciated!


#2

In the file given by

file.path(Sys.getenv("HOME"), ".R/Makevars")))

there is a

CXXFLAGS += ~O3 ...

where ~ is some misencoding of a dash. It should be a dash, followed by the capital letter 0 followed by the number 3 without spaces in between, like

CXXFLAGS += -O3 ...

#3

Wow. Thanks so much.