Stan technically requires as much of C++14 as is implemented in Rtools, but I think there is currently nothing that uses syntax that is not defined by the C++11 standard. That may not be true for long though.
I think it would work as is on Ubuntu 14.04 (srsly?) as long as it has R >= 3.4, which you may have to compile from source or get from a extra repository or something.
That worked for me. But after some compilation and linking steps, I got an error:
/usr/bin/ld: chains.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
chains.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [rstan.so] Error 1
ERROR: compilation failed for package ‘rstan’
System information:
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 7.4 (Maipo)
Release: 7.4
Codename: Maipo
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
I added CXXFLAGS = -fPIC to the Makevars file, but still got the same error. I’m afraid I don’t have permission to install a more recent g++ in this computer. I could request it, but it’s not guaranteed to happen.
Actually, I don’t see the argument -fPIC in the compiler call. So that change to Makevars didn’t seem to make an effect.
Well, g++-4.8 isn’t adequate for Stan >= 2.18 anyway, so I would go ahead and request the upgrade.
Are you multiarching or something? Googling for “relocation R_X86_64_32 against `.rodata’ can not be used when making a shared object” yields a bunch of hits.
After installing gcc tools 8.2, I’m getting an error when trying to install rstan-2.18.1 (it seems compiling terminated successfully):
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘rstan’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/bacalfa/R/x86_64-pc-linux-gnu-library/3.5/rstan/libs/rstan.so':
/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/bacalfa/R/x86_64-pc-linux-gnu-library/3.5/rstan/libs/rstan.so)
Error: loading failed
Execution halted
ERROR: loading failed
Google seems to suggest that you have an older version of libstdc++ than the one that should be present and found for g++-8. Maybe try to install the libstdc++-8-dev package?