It’s always a bit of a puzzle to install rstan from github. Maybe add some section “Install from github” in the readme? Or did I miss it? Could only find build instruction, which are less convenient. I used
which seems to work, but fails the message below. Looks like a memory problem, but I have 32 GB. I have CXX_STD = CXX11 from previous experimentation, is that ok?
from 'stan::lang::indexes_grammar<Iterator>::indexes_grammar(stan::lang::variable_map&, std::stringstream&, stan::lang::expression_grammar<Iterator>&) [with Iterator = boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> > >; std::stringstream = std::basic_stringstream<char>]'
C:/R/library/StanHeaders/include/src/stan/lang/grammars/indexes_grammar_inst.cpp:7:33: required from here
C:/R/library/BH/include/boost/spirit/home/qi/nonterminal/rule.hpp:185:9: internal compiler error: Segmentation fault
}
^
Please submit a full bug report,
Found it. Your version works when the filename is given (checked), but does does not retrieve the mc-string you use in the example. Alternatively, remove the example
Precondition: Running stan the usual way works in my setup.
Next step - tried with RStudio on Ubuntu, and on Windows as documented above
– Put fibonacci example in a file “a.stan” (since passing text currently fails)
library(rstan)
st = expose_stan_functions("a.stan")
---------------------------------------------------------
In file included from file37284ff74b42.cpp:6:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/model/standalone_functions_header.hpp:4:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/stan/math.hpp:4:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core.hpp:12:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/var.hpp:7:
In file included from /usr/local/lib/R/site-library/BH/include/boost/math/tools/config.hpp:13:
In file included from /usr/local/lib/R/site-library/BH/include/boost/config.hpp:39:
/usr/local/lib/R/site-library/BH/include/boost/config/compiler/clang.hpp:200:11: warning: 'BOOST_NO_CXX11_RVALUE_REFERENCES' macro redefined [-Wmacro-redefined]
# define BOOST_NO_CXX11_RVALUE_REFERENCES
^
<command line>:6:9: note: previous definition is here
#define BOOST_NO_CXX11_RVALUE_REFERENCES 1
^
file37284ff74b42.cpp:13:19: error: target of using declaration conflicts with declaration already in scope
using stan::math::lgamma;
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/scal/fun/lgamma.hpp:36:19: note: target of using declaration
inline double lgamma(double x) {
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:261:13: note: conflicting declaration
__MATHCALL (lgamma,, (_Mdouble_));
^
/usr/include/math.h:66:25: note: expanded from macro '__MATHCALL'
__MATHDECL (_Mdouble_,function,suffix, args)
^
/usr/include/math.h:68:22: note: expanded from macro '__MATHDECL'
__MATHDECL_1(type, function,suffix, args); \
^
/usr/include/math.h:76:31: note: expanded from macro '__MATHDECL_1'
extern type __MATH_PRECNAME(function,suffix) args __THROW
^
/usr/include/math.h:79:42: note: expanded from macro '__MATH_PRECNAME'
#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:88:23: note: expanded from macro '__CONCAT'
#define __CONCAT(x,y) x ## y
^
file37284ff74b42.cpp:34:46: error: parameter declarator cannot be qualified
fibonacci(const int& x, std::ostream* &Rcpp::Rcout);
~~~~~~^
file37284ff74b42.cpp:58:91: error: call to 'fibonacci' is ambiguous
return stan::math::promote_scalar<fun_return_scalar_t__>((logical_lte(x,2) ? 1 : (fibonacci((x - 1), pstream__) + fibonacci((x - 2), pstream__)) ));
^~~~~~~~~
file37284ff74b42.cpp:34:1: note: candidate function
fibonacci(const int& x, std::ostream* &Rcpp::Rcout);
^
file37284ff74b42.cpp:38:1: note: candidate function
fibonacci(const int& x, std::ostream* pstream__) {
^
file37284ff74b42.cpp:58:123: error: call to 'fibonacci' is ambiguous
return stan::math::promote_scalar<fun_return_scalar_t__>((logical_lte(x,2) ? 1 : (fibonacci((x - 1), pstream__) + fibonacci((x - 2), pstream__)) ));
^~~~~~~~~
file37284ff74b42.cpp:34:1: note: candidate function
fibonacci(const int& x, std::ostream* &Rcpp::Rcout);
^
file37284ff74b42.cpp:38:1: note: candidate function
fibonacci(const int& x, std::ostream* pstream__) {
^
file37284ff74b42.cpp:80:50: error: parameter declarator cannot be qualified
int fibonacci(const int& x, std::ostream*& Rcpp::Rcout);
~~~~~~^
file37284ff74b42.cpp:81:62: error: parameter declarator cannot be qualified
RcppExport SEXP sourceCpp_1_fibonacci(SEXP xSEXP, SEXP Rcpp::RcoutSEXP) {
~~~~~~^
file37284ff74b42.cpp:86:77: error: no type named 'RcoutSEXP' in namespace 'Rcpp'
Rcpp::traits::input_parameter< std::ostream*& >::type Rcpp::Rcout(Rcpp::RcoutSEXP);
~~~~~~^
file37284ff74b42.cpp:86:65: error: definition or redeclaration of 'Rcout' not allowed inside a function
Rcpp::traits::input_parameter< std::ostream*& >::type Rcpp::Rcout(Rcpp::RcoutSEXP);
~~~~~~^
file37284ff74b42.cpp:86:70: warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]
Rcpp::traits::input_parameter< std::ostream*& >::type Rcpp::Rcout(Rcpp::RcoutSEXP);
^~~~~~~~~~~~~~~~~
file37284ff74b42.cpp:86:71: note: add a pair of parentheses to declare a variable
Rcpp::traits::input_parameter< std::ostream*& >::type Rcpp::Rcout(Rcpp::RcoutSEXP);
^
(
file37284ff74b42.cpp:87:53: error: reference to 'Rcout' is ambiguous
rcpp_result_gen = Rcpp::wrap(fibonacci(x, Rcpp::Rcout));
~~~~~~^
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/iostream/Rstreambuf.h:92:28: note: candidate found by name lookup is 'Rcpp::Rcout'
static Rostream<true> Rcout;
^
file37284ff74b42.cpp:86:65: note: candidate found by name lookup is 'Rcpp::Rcout'
Rcpp::traits::input_parameter< std::ostream*& >::type Rcpp::Rcout(Rcpp::RcoutSEXP);
^
file37284ff74b42.cpp:93:17: error: redefinition of 'sourceCpp_1_fibonacci'
RcppExport SEXP sourceCpp_1_fibonacci(SEXP xSEXP, SEXP pstream__SEXP) {
^
file37284ff74b42.cpp:81:17: note: previous definition is here
RcppExport SEXP sourceCpp_1_fibonacci(SEXP xSEXP, SEXP Rcpp::RcoutSEXP) {
^
In file included from file37284ff74b42.cpp:4:
In file included from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27:
In file included from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:160:
In file included from /usr/local/lib/R/site-library/Rcpp/include/Rcpp/as.h:25:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/internal/Exporter.h:31:28: error: cannot initialize a member subobject of type 'std::basic_ostream<char> *' with an lvalue of type 'SEXP' (aka 'SEXPREC *')
Exporter( SEXP x ) : t(x){}
^ ~
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/as.h:87:41: note: in instantiation of member function 'Rcpp::traits::Exporter<std::basic_ostream<char> *>::Exporter' requested here
::Rcpp::traits::Exporter<T> exporter(x);
^
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/as.h:152:26: note: in instantiation of function template specialization 'Rcpp::internal::as<std::basic_ostream<char> *>' requested here
return internal::as<T>(x, typename traits::r_type_traits<T>::r_category());
^
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/InputParameter.h:34:38: note: in instantiation of function template specialization 'Rcpp::as<std::basic_ostream<char> *>' requested here
inline operator T() { return as<T>(x) ; }
^
file37284ff74b42.cpp:99:47: note: in instantiation of member function 'Rcpp::InputParameter<std::basic_ostream<char> *>::operator std::basic_ostream<char> *' requested here
rcpp_result_gen = Rcpp::wrap(fibonacci(x, pstream__));
^
2 warnings and 11 errors generated.
make: *** [file37284ff74b42.o] Fehler 1
clang++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include/" -I"/usr/local/lib/R/site-library/RcppEigen/include/" -I"/usr/local/lib/R/site-library/RcppEigen/include/unsupported" -I"/usr/local/lib/R/site-library/rstan/include/boost_not_in_BH" -I"/usr/local/lib/R/site-library/BH/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src/" -I"/usr/local/lib/R/site-library/StanHeaders/include/" -I"/usr/local/lib/R/site-library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_NO_CXX11_RVALUE_REFERENCES -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/rstan/include" -I"/tmp/Rtmp3pDkcc/sourceCpp-x86_64-pc-linux-gnu-0.12.13" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c file37284ff74b42.cpp -o file37284ff74b42.o
/usr/lib/R/etc/Makeconf:168: die Regel für Ziel „file37284ff74b42.o“ scheiterte
Fehler in Rcpp::sourceCpp(code = paste(code, collapse = "\n"), ...) :
Error 1 occurred building shared library.