Rstan Compilation Hangs

I recently updated to R v4. I am mac OS X Catalina (the perfect storm right)

I followed these instructions to the letter: https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/

The only difference is that after doing that I was still getting error messages when trying to run the RcppArmadillo test it suggested. I found an pre R4.0 makevars file suggested for use with Stan on Catalina which worked out and now Rcpp works fine.

# https://mirror.its.sfu.ca/mirror/CRAN/bin/macosx/tools/
# https://mirror.its.sfu.ca/mirror/CRAN/bin/macosx/tools/
# https://github.com/Rdatatable/data.table/wiki/Installation
# https://asieira.github.io/using-openmp-with-r-packages-in-os-x.html
# https://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/
# https://mirror.its.sfu.ca/mirror/CRAN/bin/macosx/
# https://mirror.its.sfu.ca/mirror/CRAN/bin/macosx/tools/
# https://luispuerto.net/blog/2018/01/12/install-r-100-homebrew-edition-with-openblas-openmp-my-version/#data-table-package
# https://www.kthohr.com/r-mac-source.html

XCBASE:=$(shell xcrun --show-sdk-path)
LLVMBASE:=$(shell brew --prefix llvm)
GCCBASE:=$(shell brew --prefix gcc)
GETTEXT:=$(shell brew --prefix gettext)

CC=$(LLVMBASE)/bin/clang
CXX=$(LLVMBASE)/bin/clang++
CXX11=$(LLVMBASE)/bin/clang++
CXX14=$(LLVMBASE)/bin/clang++
CXX17=$(LLVMBASE)/bin/clang++
CXX1X=$(LLVMBASE)/bin/clang++
SHLIB_CXXLD=$(LLVMBASE)/bin/clang++

CXX1XSTD=-std=c++0x

CPPFLAGS=-isysroot "$(XCBASE)" -isystem "$(LLVMBASE)/include" -isystem "$(GETTEXT)/include"
CFLAGS=-O3 -mtune=native -pipe
CXXFLAGS=-O3 -mtune=native -pipe
LDFLAGS=--sysroot "$(XCBASE)" -L "$(LLVMBASE)/lib" -L "$(GETTEXT)/lib"
PKG_CXXFLAGS=-std=c++11

FC=$(GCCBASE)/bin/gfortran
F77=$(GCCBASE)/bin/gfortran
FLIBS=-L$(GCCBASE)/lib/gcc/9/ -lm
MAKE=make -j8

SHLIB_OPENMP_CFLAGS=-fopenmp
SHLIB_OPENMP_CXXFLAGS=-fopenmp
SHLIB_OPENMP_FCFLAGS=-fopenmp
SHLIB_OPENMP_FFLAGS=-fopenmp

# Only use -fopenmp if OpemMP is available
# https://github.com/Rdatatable/data.table/issues/2161
ifeq ($(shell $(CXX11) -fopenmp -E -xc++ - 2>&1 >/dev/null && echo 'true'), true)
  CFLAGS+=$(SHLIB_OPENMP_CFLAGS)
  CXXFLAGS+=$(SHLIB_OPENMP_CXXFLAGS)
  FCFLAGS+=$(SHLIB_OPENMP_FCFLAGS)
  FFLAGS+=$(SHLIB_OPENMP_FFLAGS)
endif

I installed rstan from source (without errors) using the above makevars file.

But when I try to run stan it just hangs. It doesn’t’ even error, during compilation it just never finishes. I have been waiting on the following for about 10 minutes now.

8schools example also does the same thing.

example(stan_model, package = "rstan", run.dontrun = TRUE)

stn_md> stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}'

stn_md> mod <- stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL '16a540c6086086816528e4524def24d9' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model '16a540c6086086816528e4524def24d9'.

I am completely confused and any help would be very appreciated.

Thank you!

Do you see the compiler running in Activity Monitor?

Yes I do.

Clang-10. Though it says its using 0% of my CPU.

Also when running 8schools everytime I stop it through Rstudio I get the followign error:

Error in if (!is.null(attr(CXX, “status”)) || nchar(CXX) == 0) { :
missing value where TRUE/FALSE needed

Not sure if any of this is sensical to you.

If you do

rstan:::get_CXX()

what does it say?

rstan::get_CXX()
Error: ‘get_CXX’ is not an exported object from ‘namespace:rstan’
rstan:::get_adaptation_info_CXX()
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object ‘get_adaptation_info_CXX’ not found

interestingly in Rstudio

rstan:::get_CXX()
is still running…

never mind:

library(rstan)
rstan:::get_CXX()

gives:
“/usr/local/opt/llvm/bin/clang++”

but rstudio still is not finished running even that.

Does RStan work outside of RStudio?

Welll… it goes farther than in RStudio

> schools_dat <- list(J = 8, 
+                     y = c(28,  8, -3,  7, -1,  1, 18, 12),
+                     sigma = c(15, 10, 16, 11,  9, 11, 10, 18))
> 
> fit <- stan(file = 'schools.stan', data = schools_dat)

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:535:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.
In addition: Warning message:
In system(cmd, intern = !verbose) :
  running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file37334cbd80ae.cpp 2> file37334cbd80ae.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection

Can you do

example(stan_model, package = "rstan", run.dontrun = TRUE)

outside RStudio and tell me the line below the line that says “Compilation argument” and anything that refers to error: (with the colon)?

Compilation argument:
 /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file3d506553adca.cpp 2> file3d506553adca.cpp.err.txt 
/usr/local/opt/llvm/bin/clang++ -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -D_REENTRANT  -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp   -isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" -isystem "/usr/local/opt/llvm/include" -isystem "/usr/local/opt/gettext/include"  -std=c++11 -fPIC  -Wall -g -O2  -c file3d506553adca.cpp -o file3d506553adca.o

and errors:
18 warnings and 19 errors generated.
make: *** [file3d506553adca.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: 
  2: // includes from the plugin
  3: // [[Rcpp::plugins(cpp14)]]
  4: 
  5: // user includes
  6: #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
  7: #include <rstan/rstaninc.hpp>
  8: // Code generated by Stan version 2.19.1
  9: 
 10: #include <stan/model/model_header.hpp>
 11: 
 12: namespace model3d5044bce955_16a540c6086086816528e4524def24d9_namespace {
 13: 
 14: using std::istream;
 15: using std::string;
 16: using std::stringstream;
 17: using std::vector;
 18: using stan::io::dump;
 19: using stan::math::lgamma;
 20: using stan::model::prob_grad;
 21: using namespace stan::math;
 22: 
 23: static int current_statement_begin__;
 24: 
 25: stan::io::program_reader prog_reader__() {
 26:     stan::io::program_reader reader;
 27:     reader.add_event(0, 0, "start", "model3d5044bce955_16a540c6086086816528e4524def24d9");
 28:     reader.add_event(3, 1, "end", "model3d5044bce955_16a540c6086086816528e4524def24d9");
 29:     return reader;
 30: }
 31: 
 32: class model3d5044bce955_16a540c6086086816528e4524def24d9 : public prob_grad {
 33: private:
 34:         double y_mean;
 35: public:
 36:     model3d5044bce955_16a540c6086086816528e4524def24d9(stan::io::var_context& context__,
 37:         std::ostream* pstream__ = 0)
 38:         : prob_grad(0) {
 39:         ctor_body(context__, 0, pstream__);
 40:     }
 41: 
 42:     model3d5044bce955_16a540c6086086816528e4524def24d9(stan::io::var_context& context__,
 43:         unsigned int random_seed__,
 44:         std::ostream* pstream__ = 0)
 45:         : prob_grad(0) {
 46:         ctor_body(context__, random_seed__, pstream__);
 47:     }
 48: 
 49:     void ctor_body(stan::io::var_context& context__,
 50:                    unsigned int random_seed__,
 51:                    std::ostream* pstream__) {
 52:         typedef double local_scalar_t__;
 53: 
 54:         boost::ecuyer1988 base_rng__ =
 55:           stan::services::util::create_rng(random_seed__, 0);
 56:         (void) base_rng__;  // suppress unused var warning
 57: 
 58:         current_statement_begin__ = -1;
 59: 
 60:         static const char* function__ = "model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9";
 61:         (void) function__;  // dummy to suppress unused var warning
 62:         size_t pos__;
 63:         (void) pos__;  // dummy to suppress unused var warning
 64:         std::vector<int> vals_i__;
 65:         std::vector<double> vals_r__;
 66:         local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 67:         (void) DUMMY_VAR__;  // suppress unused var warning
 68: 
 69:         try {
 70:             // initialize data block variables from context__
 71:             current_statement_begin__ = 1;
 72:             context__.validate_dims("data initialization", "y_mean", "double", context__.to_vec());
 73:             y_mean = double(0);
 74:             vals_r__ = context__.vals_r("y_mean");
 75:             pos__ = 0;
 76:             y_mean = vals_r__[pos__++];
 77: 
 78: 
 79:             // initialize transformed data variables
 80:             // execute transformed data statements
 81: 
 82:             // validate transformed data
 83: 
 84:             // validate, set parameter ranges
 85:             num_params_r__ = 0U;
 86:             param_ranges_i__.clear();
 87:             current_statement_begin__ = 1;
 88:             num_params_r__ += 1;
 89:         } catch (const std::exception& e) {
 90:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
 91:             // Next line prevents compiler griping about no return
 92:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 93:         }
 94:     }
 95: 
 96:     ~model3d5044bce955_16a540c6086086816528e4524def24d9() { }
 97: 
 98: 
 99:     void transform_inits(const stan::io::var_context& context__,
100:                          std::vector<int>& params_i__,
101:                          std::vector<double>& params_r__,
102:                          std::ostream* pstream__) const {
103:         typedef double local_scalar_t__;
104:         stan::io::writer<double> writer__(params_r__, params_i__);
105:         size_t pos__;
106:         (void) pos__; // dummy call to supress warning
107:         std::vector<double> vals_r__;
108:         std::vector<int> vals_i__;
109: 
110:         current_statement_begin__ = 1;
111:         if (!(context__.contains_r("y")))
112:             stan::lang::rethrow_located(std::runtime_error(std::string("Variable y missing")), current_statement_begin__, prog_reader__());
113:         vals_r__ = context__.vals_r("y");
114:         pos__ = 0U;
115:         context__.validate_dims("parameter initialization", "y", "double", context__.to_vec());
116:         double y(0);
117:         y = vals_r__[pos__++];
118:         try {
119:             writer__.scalar_unconstrain(y);
120:         } catch (const std::exception& e) {
121:             stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable y: ") + e.what()), current_statement_begin__, prog_reader__());
122:         }
123: 
124:         params_r__ = writer__.data_r();
125:         params_i__ = writer__.data_i();
126:     }
127: 
128:     void transform_inits(const stan::io::var_context& context,
129:                          Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
130:                          std::ostream* pstream__) const {
131:       std::vector<double> params_r_vec;
132:       std::vector<int> params_i_vec;
133:       transform_inits(context, params_i_vec, params_r_vec, pstream__);
134:       params_r.resize(params_r_vec.size());
135:       for (int i = 0; i < params_r.size(); ++i)
136:         params_r(i) = params_r_vec[i];
137:     }
138: 
139: 
140:     template <bool propto__, bool jacobian__, typename T__>
141:     T__ log_prob(std::vector<T__>& params_r__,
142:                  std::vector<int>& params_i__,
143:                  std::ostream* pstream__ = 0) const {
144: 
145:         typedef T__ local_scalar_t__;
146: 
147:         local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
148:         (void) DUMMY_VAR__;  // dummy to suppress unused var warning
149: 
150:         T__ lp__(0.0);
151:         stan::math::accumulator<T__> lp_accum__;
152:         try {
153:             stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
154: 
155:             // model parameters
156:             current_statement_begin__ = 1;
157:             local_scalar_t__ y;
158:             (void) y;  // dummy to suppress unused var warning
159:             if (jacobian__)
160:                 y = in__.scalar_constrain(lp__);
161:             else
162:                 y = in__.scalar_constrain();
163: 
164:             // model body
165: 
166:             current_statement_begin__ = 1;
167:             lp_accum__.add(normal_log<propto__>(y, y_mean, 1));
168: 
169:         } catch (const std::exception& e) {
170:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
171:             // Next line prevents compiler griping about no return
172:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
173:         }
174: 
175:         lp_accum__.add(lp__);
176:         return lp_accum__.sum();
177: 
178:     } // log_prob()
179: 
180:     template <bool propto, bool jacobian, typename T_>
181:     T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
182:                std::ostream* pstream = 0) const {
183:       std::vector<T_> vec_params_r;
184:       vec_params_r.reserve(params_r.size());
185:       for (int i = 0; i < params_r.size(); ++i)
186:         vec_params_r.push_back(params_r(i));
187:       std::vector<int> vec_params_i;
188:       return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
189:     }
190: 
191: 
192:     void get_param_names(std::vector<std::string>& names__) const {
193:         names__.resize(0);
194:         names__.push_back("y");
195:     }
196: 
197: 
198:     void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
199:         dimss__.resize(0);
200:         std::vector<size_t> dims__;
201:         dims__.resize(0);
202:         dimss__.push_back(dims__);
203:     }
204: 
205:     template <typename RNG>
206:     void write_array(RNG& base_rng__,
207:                      std::vector<double>& params_r__,
208:                      std::vector<int>& params_i__,
209:                      std::vector<double>& vars__,
210:                      bool include_tparams__ = true,
211:                      bool include_gqs__ = true,
212:                      std::ostream* pstream__ = 0) const {
213:         typedef double local_scalar_t__;
214: 
215:         vars__.resize(0);
216:         stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
217:         static const char* function__ = "model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::write_array";
218:         (void) function__;  // dummy to suppress unused var warning
219: 
220:         // read-transform, write parameters
221:         double y = in__.scalar_constrain();
222:         vars__.push_back(y);
223: 
224:         double lp__ = 0.0;
225:         (void) lp__;  // dummy to suppress unused var warning
226:         stan::math::accumulator<double> lp_accum__;
227: 
228:         local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
229:         (void) DUMMY_VAR__;  // suppress unused var warning
230: 
231:         if (!include_tparams__ && !include_gqs__) return;
232: 
233:         try {
234:             if (!include_gqs__ && !include_tparams__) return;
235:             if (!include_gqs__) return;
236:         } catch (const std::exception& e) {
237:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
238:             // Next line prevents compiler griping about no return
239:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
240:         }
241:     }
242: 
243:     template <typename RNG>
244:     void write_array(RNG& base_rng,
245:                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
246:                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
247:                      bool include_tparams = true,
248:                      bool include_gqs = true,
249:                      std::ostream* pstream = 0) const {
250:       std::vector<double> params_r_vec(params_r.size());
251:       for (int i = 0; i < params_r.size(); ++i)
252:         params_r_vec[i] = params_r(i);
253:       std::vector<double> vars_vec;
254:       std::vector<int> params_i_vec;
255:       write_array(base_rng, params_r_vec, params_i_vec, vars_vec, include_tparams, include_gqs, pstream);
256:       vars.resize(vars_vec.size());
257:       for (int i = 0; i < vars.size(); ++i)
258:         vars(i) = vars_vec[i];
259:     }
260: 
261:     static std::string model_name() {
262:         return "model3d5044bce955_16a540c6086086816528e4524def24d9";
263:     }
264: 
265: 
266:     void constrained_param_names(std::vector<std::string>& param_names__,
267:                                  bool include_tparams__ = true,
268:                                  bool include_gqs__ = true) const {
269:         std::stringstream param_name_stream__;
270:         param_name_stream__.str(std::string());
271:         param_name_stream__ << "y";
272:         param_names__.push_back(param_name_stream__.str());
273: 
274:         if (!include_gqs__ && !include_tparams__) return;
275: 
276:         if (include_tparams__) {
277:         }
278: 
279:         if (!include_gqs__) return;
280:     }
281: 
282: 
283:     void unconstrained_param_names(std::vector<std::string>& param_names__,
284:                                    bool include_tparams__ = true,
285:                                    bool include_gqs__ = true) const {
286:         std::stringstream param_name_stream__;
287:         param_name_stream__.str(std::string());
288:         param_name_stream__ << "y";
289:         param_names__.push_back(param_name_stream__.str());
290: 
291:         if (!include_gqs__ && !include_tparams__) return;
292: 
293:         if (include_tparams__) {
294:         }
295: 
296:         if (!include_gqs__) return;
297:     }
298: 
299: }; // model
300: 
301: }  // namespace
302: 
303: typedef model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9 stan_model;
304: 
305: /**
306:  * Define Rcpp Module to expose stan_fit's functions to R.
307:  */
308: RCPP_MODULE(stan_fit4model3d5044bce955_16a540c6086086816528e4524def24d9_mod){
309:   Rcpp::class_<rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9,
310:                boost::random::ecuyer1988> >("stan_fit4model3d5044bce955_16a540c6086086816528e4524def24d9")
311:     // .constructor<Rcpp::List>()
312:     .constructor<SEXP, SEXP, SEXP>()
313:     // .constructor<SEXP, SEXP>()
314:     .method("call_sampler",
315:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::call_sampler)
316:     .method("param_names",
317:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_names)
318:     .method("param_names_oi",
319:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_names_oi)
320:     .method("param_fnames_oi",
321:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_fnames_oi)
322:     .method("param_dims",
323:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_dims)
324:     .method("param_dims_oi",
325:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_dims_oi)
326:     .method("update_param_oi",
327:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::update_param_oi)
328:     .method("param_oi_tidx",
329:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_oi_tidx)
330:     .method("grad_log_prob",
331:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::grad_log_prob)
332:     .method("log_prob",
333:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::log_prob)
334:     .method("unconstrain_pars",
335:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::unconstrain_pars)
336:     .method("constrain_pars",
337:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::constrain_pars)
338:     .method("num_pars_unconstrained",
339:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::num_pars_unconstrained)
340:     .method("unconstrained_param_names",
341:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::unconstrained_param_names)
342:     .method("constrained_param_names",
343:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::constrained_param_names)
344:     .method("standalone_gqs",
345:             &rstan::stan_fit<model3d5044bce955_16a540c6086086816528e4524def24d9_namespace::model3d5044bce955_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::standalone_gqs)
346:   ;
347: }
348: 
349: // declarations
350: extern "C" {
351: SEXP file3d506553adca( ) ;
352: }
353: 
354: // definition
355: 
356: SEXP file3d506553adca(  ){
357:  return Rcpp::wrap("16a540c6086086816528e4524def24d9");
358: }
359: 
360: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:535:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.

The compilation argument seems fine but the paste of the output got truncated at

Maybe I am missing something but that was the end of the error output – unless I am being really dense:

There might be a file in tempdir() ending with _error.txt that could have more information.

not that I see:

Any other ideas as to how to trouble-shoot this?

Try calling Rcpp::sourceCpp(file.path(tempdir(), "file3d506554adca.cpp")

> Rcpp::sourceCpp(file.path(tempdir(), "file3d506553adca.cpp"))
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:535:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:2:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/LU:47:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Cholesky:12:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Jacobi:29:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Cholesky:43:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/QR:17:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Householder:27:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:5:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/SVD:48:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:6:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Geometry:58:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Eigenvalues:58:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
file3d506553adca.cpp:6:36: warning: ISO C99 requires whitespace after the macro name [-Wc99-extensions]
#define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
                                   ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigen.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigenForward.h:31:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Sparse:26:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/SparseCore:66:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigen.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigenForward.h:31:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Sparse:27:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/OrderingMethods:71:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigen.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigenForward.h:31:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Reso/usr/local/opt/llvm/bin/clang++ -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -D_REENTRANT  -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I"/private/var/folders/x1/9_lpy_fs0kvg0p88td6_df200000gq/T/RtmpJP49oK" -isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" -isystem "/usr/local/opt/llvm/include" -isystem "/usr/local/opt/gettext/include"  -std=c++11 -fPIC  -Wall -g -O2  -c file3d506553adca.cpp -o file3d506553adca.o
Error in Rcpp::sourceCpp(file.path(tempdir(), "file3d506553adca.cpp")) : 
  Error 1 occurred building shared library.
orks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/KroneckerProduct:34:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/../../Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigen.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigenForward.h:39:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/Polynomials:135:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/../../Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigen.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigenForward.h:40:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/SparseExtra:51:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/../../Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:41:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:31:27: error: no template named 'index_sequence' in namespace 'std'; did you mean 'boost::fusion::detail::index_sequence'?
                          std::index_sequence<I...> i) {
                          ^~~~~~~~~~~~~~~~~~~
                          boost::fusion::detail::index_sequence
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include/boost/fusion/support/detail/index_sequence.hpp:37:12: note: 'boost::fusion::detail::index_sequence' declared here
    struct index_sequence
           ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/
WARNING: The tools required to build C++ code for R were not found.

Please install Command Line Tools for XCode (or equivalent).

R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:41:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:30:11: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
constexpr auto apply_impl(const F& f, const Tuple& t,
          ^
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:48:11: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
constexpr auto apply(const F& f, const Tuple& t) {
          ^
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:27: error: no template named 'make_index_sequence' in namespace 'std'; did you mean 'boost::fusion::detail::make_index_sequence'?
  return apply_impl(f, t, std::make_index_sequence<std::tuple_size<Tuple>{}>{});
                          ^~~~~~~~~~~~~~~~~~~~~~~~
                          boost::fusion::detail::make_index_sequence
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include/boost/fusion/support/detail/index_sequence.hpp:59:12: note: 'boost::fusion::detail::make_index_sequence' declared here
    struct make_index_sequence
           ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:41:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:151:14: error: no template named 'result_of_t' in namespace 'std'; did you mean 'result_of'?
      = std::result_of_t<F(decltype(is_var_), decltype(value_of(Targs()))...)>;
        ~~~~~^~~~~~~~~~~
             result_of
/usr/local/opt/llvm/bin/../include/c++/v1/type_traits:2521:34: note: 'result_of' declared here
template <class _Callable> class result_of;
                                 ^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:41:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:408:3: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
  auto operator()(const Targs&... args) {
  ^
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:536:16: error: 'auto' not allowed in lambda parameter
        [this](auto&&... args) { this->accumulate_adjoints(args...); },
               ^~~~
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:536:22: error: type 'int &&' of function parameter pack does not contain any unexpanded parameter packs
        [this](auto&&... args) { this->accumulate_adjoints(args...); },
               ~~~~~~^~~~~~~~
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:616:1: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
auto adj_jac_apply(const Targs&... args) {
^
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:41:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:60:3: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
  auto multiply_adjoint_jacobian(const std::array<bool, size>& needs_adj,
  ^
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:73:12: error: no viable conversion from returned value of type 'tuple<typename __unwrap_ref_decay<Matrix<double, -1, 1, 0, -1, 1> &>::type>' (aka 'tuple<Eigen::Matrix<double, -1, 1, 0, -1, 1> >') to function return type 'int'
    return std::make_tuple(adj_times_jac);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:88:10: error: no matching function for call to 'adj_jac_apply'
  return adj_jac_apply<internal::ordered_constrain_op>(x);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:42:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/positive_ordered_constrain.hpp:61:3: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
  auto multiply_adjoint_jacobian(const std::array<bool, size>& needs_adj,
  ^
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/positive_ordered_constrain.hpp:71:12: error: no viable conversion from returned value of type 'tuple<typename __unwrap_ref_decay<Matrix<double, -1, 1, 0, -1, 1> &>::type>' (aka 'tuple<Eigen::Matrix<double, -1, 1, 0, -1, 1> >') to function return type 'int'
    return std::make_tuple(adj_times_jac);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/positive_ordered_constrain.hpp:86:10: error: no matching function for call to 'adj_jac_apply'
  return adj_jac_apply<internal::positive_ordered_constrain_op>(x);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:48:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/simplex_constrain.hpp:66:3: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
  auto multiply_adjoint_jacobian(const std::array<bool, size>& needs_adj,
  ^
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/simplex_constrain.hpp:79:12: error: no viable conversion from returned value of type 'tuple<typename __unwrap_ref_decay<Matrix<double, -1, 1, 0, -1, 1> &>::type>' (aka 'tuple<Eigen::Matrix<double, -1, 1, 0, -1, 1> >') to function return type 'int'
    return std::make_tuple(adj_times_jac);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/simplex_constrain.hpp:97:10: error: no matching function for call to 'adj_jac_apply'
  return adj_jac_apply<internal::simplex_constrain_op>(y);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from file3d506553adca.cpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:49:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/softmax.hpp:78:10: error: no matching function for call to 'adj_jac_apply'
  return adj_jac_apply<internal::softmax_op>(alpha);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 warnings and 19 errors generated.
make: *** [file3d506553adca.o] Error 1

There are a few Google hits for this error message or similar.

I think the main answer is that we currently don’t know how to compile models on Macs without using the XCode toolchain because R, Rcpp, etc. are built with XCode. I hope we get it figured out someday and if I used a Mac, I would be angry that CRAN based everything on a proprietary compiler despite ostensibly being a GNU project.

1 Like

Ok so I took a step back… I am running through @coatless recommendations again:

No custom Makevars just … no Makevars…

Now hello_world.cpp fails:

Any ideas? Any ideas on where I should post for help?

> Rcpp::sourceCpp('Downloads/helloworld.cpp')
In file included from helloworld.cpp:1:
In file included from /Users/Justin/Library/R/4.0/library/RcppArmadillo/include/RcppArmadillo.h:31:
In file included from /Users/Justin/Library/R/4.0/library/RcppArmadillo/include/RcppArmadilloForward.h:26:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/RcppCommon.h:29:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/Rcpp/r/headers.h:67:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/Rcpp/platform/compiler.h:100:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:314:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:315:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:316:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/usr/local/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from helloworld.cpp:1:
In file included from /Users/Justin/Library/R/4.0/library/RcppArmadillo/include/RcppArmadillo.h:31:
In file included from /Users/Justin/Library/R/4.0/library/RcppArmadillo/include/RcppArmadilloForward.h:26:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/RcppCommon.h:29:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/Rcpp/r/headers.h:67:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/Rcpp/platform/compiler.h:100:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isgreater' in the global namespace
using ::isgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'isgreaterequal' in the global namespace
using ::isgreaterequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:332:9: error: no member named 'abs' in the global namespace; did you mean 'fabs'?
using ::abs;
      ~~^
/usr/local/include/math.h:417:15: note: 'fabs' declared here
extern double fabs(double);
              ^
In file included from helloworld.cpp:1:
In file included from /Users/Justin/Library/R/4.0/library/RcppArmadillo/include/RcppArmadillo.h:31:
In file included from /Users/Justin/Library/R/4.0/library/RcppArmadillo/include/RcppArmadilloForward.h:26:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/RcppCommon.h:29:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/Rcpp/r/headers.h:67:
In file included from /Users/Justin/Library/R/4.0/library/Rcpp/include/Rcpp/platform/compiler.h:100:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:552:28: error: expected a qualified name after 'typename'
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:552:37: error: expected ';' at end of declaration
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
                                    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:552:37: error: expected unqualified-id
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:564:39: error: use of undeclared identifier 'is_floating_point'
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
                                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:564:57: error: '_A1' does not refer to a value
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
                                                        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:562:17: note: declared here
template <class _A1>
                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [helloworld.o] Error 1
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include   -I"/Users/Justin/Library/R/4.0/library/Rcpp/include" -I"/Users/Justin/Library/R/4.0/library/RcppArmadillo/include" -I"/Users/Justin/Downloads" -I/usr/local/include   -fPIC  -Wall -g -O2  -c helloworld.cpp -o helloworld.o
Error in Rcpp::sourceCpp("Downloads/helloworld.cpp") : 
  Error 1 occurred building shared library.