Toolchain compiler error to install rstan


#1

Hi- I am using R version 3.4.3 and installing RStan following instructions listed here: https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows#toolchain and am unsuccessful in initializing brms, which I believe is associated with an inability to compile the C++ data through the RTools program. Any advice for how to resolve this issue would be appreciated. I hope that my description of the errors is thorough and will allow someone familiar with the issue to point out my problem.

I have installed toolchain with RTools into my C:/ drive and have selected the path box.

When I check Sys.getenv(‘PATH’) it does not include the gcc line as mentioned in the instructions (beginning of output below)

"C:\Rtools\bin;C:\Program Files\R\R-3.4.3\bin\x64;c:\Rtools\bin;c:\Rtools\mingw_32 […]

Checking system(‘g++ -v’) provides a long summary that does not exactly match the output suggested on the site

Using built-in specs.
COLLECT_GCC=c:\Rtools\mingw_32\bin\G__~1.EXE
COLLECT_LTO_WRAPPER=c:/Rtools/mingw_32/bin/…/libexec/gcc/i686-w64-mingw32/4.9.3/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: …/…/…/src/gcc-4.9.3/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/home/Jeroen/mingw-gcc-4.9.3/i686-493-posix-dwarf-rt_v3-s/mingw32 --with-gxx-include-dir=/mingw32/i686-w64-mingw32/include/c++ --enable-static --disable-shared --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjlj-exceptions --with-dwarf2 --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-w64-mingw32-static --with-mpfr=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-w64-mingw32-static --with-mpc=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-w64-mingw32-static --with-isl=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-w64-mingw32-static --with-cloog=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion=‘i686-posix-dwarf, Built by MinGW-W64 project’ --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS=’-O2 -pipe -I/home/Jeroen/mingw-gcc-4.9.3/i686-493-posix-dwarf-rt_v3-s/mingw32/opt/include -I/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-zlib-static/include -I/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-w64-mingw32-static/include’ CXXFLAGS=’-O2 -pipe -I/home/Jeroen/mingw-gcc-4.9.3/i686-493-posix-dwarf-rt_v3-s/mingw32/opt/include -I/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-zlib-static/include -I/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-w64-mingw32-static/include’ CPPFLAGS= LDFLAGS=’-pipe -L/home/Jeroen/mingw-gcc-4.9.3/i686-493-posix-dwarf-rt_v3-s/mingw32/opt/lib -L/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-zlib-static/lib -L/home/Jeroen/mingw-gcc-4.9.3/prerequisites/i686-w64-mingw32-static/lib -Wl,–large-address-aware’
Thread model: posix
gcc version 4.9.3 (i686-posix-dwarf, Built by MinGW-W64 project)

I have not created a personal MakeVars file because I cannot figure out how

When I check if toolchain is working following this code:

fx <- inline::cxxfunction( signature(x = “integer”, y = “numeric” ) , ‘
return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
’ )

It returns the following error:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! C:\Rtools\mingw_64\bin\nm.exe: file26481be4617a.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

When I try to run an example brm this is the error:

Compiling the C++ model
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/Robert/Documents/R/win-library/3.4/BH/include/boost/config.hpp:39:0,
from C:/Users/Robert/Documents/R/win-library/3.4/BH/include/boost/math/tools/config.hpp:13,
from C:/Users/Robert/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/core/var.hpp:7,
from C:/Users/Robert/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
from C:/Users/Robert/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/core.hpp:12,
from C:/Users/Robert/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/mat.hpp:4,
from C:/Users/Robert/Documents/R/win-library/3.4/StanHeaders/include/stan/math.hpp:4,
from C:/Users/Robert/Documents/R/win-library/3.4/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file26483f9c183

Regards,

Robert


#2

Eliminate -flto and -flto-fat-objects from the CXXFLAGS lines in the text file whose path is

normalizePath("~/.R/Makevars")

#3

Hi- thank you so kindly for your quick and helpful response and so sorry for my ignorance, I can’t find where this file would be located to remove the -flto and -flto-fat-objects


#4

What does

normalizePath("~/.R/Makevars")

say? Just open that file in the RStudio editor.


#5

I checked that file path and opened it in RStudio, then deleted two lines and the compiler is now functional, at least insofar as no longer producing an error when running code through the package brms. How incredibly thankful I am for your guidance.

Robert


#6

Hi Robert

Im having a similar problem that you had. I cant find the lines that I need to delete!


#7

If I recall correctly that file should be on your computer- if you open the file in RStudio you can delete the lines, save the file, and it should run


#8

Thanks Robert. I found it. File is running