Issue reinstalling Rstan to the new machine

rstan

#1

Operating System: Windows 10

I was using Rstan fine with the previous machine, but because of the hardware issue, I had to get a new machine.

While getting a new machine, I transferred all of my data from the previous machine instead of the programs. (e.g. R, LaTex and etc.)

Therefore, I tried to reinstall Rstan on the new machine and failed.

This is the last step of the installation step and it produces a weird error that I cannot find a solution for.

Below is the what it shows:

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

  • return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
  •                        ' )
    

C:\Rtools\mingw_64\bin\nm.exe: file32005aab6578.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 file32005aab6578( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file32005aab6578( 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: file32005aab6578.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 ) # should be 10
Error in fx(2L, 5) : could not find function “fx”

Can you please let me know what I should do to fix this?


#2

Take -flto -ffat-lto-objects out of the CXXFLAGS line in the file whose path is whatever

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

evaluates to.


Which Rtool version
#3

I don’t see
-flto -ffat-lto-objects
in my Makevars file.

Below is what I see in my Makevars file.

CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function

CXXFLAGS += -Wno-ignored-attributes -Wno-deprecated-declarations

CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function

CXXFLAGS += -flto -Wno-ignored-attributes -Wno-deprecated-declarations

CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function

CXXFLAGS += -flto -Wno-ignored-attributes -Wno-deprecated-declarations

Is there something else I need to change in this file to fix the issue?


#4

OK, just remove all the -flto then. Actually you can just replace everything with

CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function

Failing to install rstan on Windows 7
#5

Thank you very much!

This worked!!


#6

Worked for me, too.