Error during compilation

Dear experts,
I updated the rstan and then it failed to work (Rstudio always crashes at the beginning of the modeling). Then I uninstalled the Rtools and re-do the compilation according to the guide. However it failed when I did the fx test:

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

  • return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
  • ’ )
    C:\Rtools\mingw_64\bin\nm.exe: file61437cd1e.o: plugin needed to handle lto object
    Cannot export __gnu_lto_slim: symbol not defined
    Cannot export __gnu_lto_v1: symbol not defined
    collect2.exe: error: ld returned 1 exit status

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 file61437cd1e( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file61437cd1e( 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! C:\Rtools\mingw_64\bin\nm.exe: file61437cd1e.o: plugin needed to handle lto object
Cannot export __gnu_lto_slim: symbol not defined
Cannot export __gnu_lto_v1: symbol not defined
collect2.exe: error: ld returned 1 exit status

fx( 2L, 5 )
Error: could not find function “fx”

My session information is listed below:

sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] tools_3.3.0 inline_0.3.14

 Could any help me to figure this out? Thanks a lot for your help!

Best,
Yang

Remove anything pertaining to -flto and / or -ffat-lto-objects from the CXXFLAGS line in the file whose path is

normalizePath("~/.R/Makevars")

Hi Ben,
Thanks a lot for your quick reply. I tried what you suggested and it worked :-) To be more specific, I made the following changes:
The original code in the online guide (https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows):
cat("\nCXXFLAGS += -flto -Wno-ignored-attributes -Wno-deprecated-declarations",
file = M, sep = “\n”, append = TRUE)
The corrected version:
cat("\nCXXFLAGS += -Wno-ignored-attributes -Wno-deprecated-declarations",
file = M, sep = “\n”, append = TRUE)

However, there is some other warning message while the model is running:

recompiling to avoid crashing R session
In file included from F:/programinstall/R-3.3.0/library/BH/include/boost/config.hpp:39:0,
from F:/programinstall/R-3.3.0/library/BH/include/boost/math/tools/config.hpp:13,
from F:/programinstall/R-3.3.0/library/StanHeaders/include/stan/math/rev/core/var.hpp:7,
from F:/programinstall/R-3.3.0/library/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
from F:/programinstall/R-3.3.0/library/StanHeaders/include/stan/math/rev/core.hpp:12,
from F:/programinstall/R-3.3.0/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
from F:/programinstall/R-3.3.0/library/StanHeaders/include/stan/math.hpp:4,
from F:/programinstall/R-3.3.0/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file13303739252b.cpp:8:
F:/programinstall/R-3.3.0/library/BH/include/boost/config/compiler/gcc.hpp:186:0: warning: “BOOST_NO_CXX11_RVALUE_REFERENCES” redefined

define BOOST_NO_CXX11_RVALUE_REFERENCES

^
:0:0: note: this is the location of the previous definition
cc1plus.exe: warning: unrecognized command line option “-Wno-ignored-attributes”

 I wonder whether it is a stan bug or something I did wrong. Looking forward to your reply and thanks a lot!

Best,
Yang

Don’t worry about that.

Alright! Thanks :-)