0

I get an error when trying to fit a stan model in R at work's windows machine, I am pretty sure there is no issue with my coding, since it all works fine in my personal linux machine, due to the length of the error message I paste it at the end. Furthermore, the error dump states that I should open a bug report, but I am hardpressed to believe there is a bug, since the code actually works in a different computer.

Now, for what I have gathered from other users getting, I am lead to believe that I have an issue either with my Rcpp library, Rtools installation or my c++ compiler. So I tried to use Rcpp, wich works OK in Rstudio, but fails if run in emacs:

library(Rcpp)
cppFunction('int add(int x, int y, int z) {
  int sum = x + y + z;
  return sum;
}')
## console output in Rstudio
> add
function (x, y, z) 
.Primitive(".Call")(<pointer: 0x00000000712815a0>, x, y, z)
> add(1, 2,3)
[1] 6

## console output in emacs
Warning message:
running command 'make -f "c:/Users/e048366/DOCUME~1/R/R-34~1.3/etc/x64/Makeconf" -f "c:/Users/e048366/DOCUME~1/R/R-34~1.3/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="sourceCpp_2.dll" WIN=64 TCLBIN=64 OBJECTS="file3fc4d234034.o"' had status 127 

Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir,  : 
  Error 1 occurred building shared library.

WARNING: The tools required to build C++ code for R were not found.

Please download and install the appropriate version of Rtools:

http://cran.r-project.org/bin/windows/Rtools/

Now, the errors are very similar, and lead me to believe the issue is in the system PATH, since Rtools is installed, g++ compiler is installed, checking g++ --version at the cmd states that I have version 4.9.3 installed and Rstudio seems to find the compiler, but I have updated the PATH, since earlier I found an error saying that no c++ compiler was found, and now it finds the compiler, but does not compile.

> library(tidyverse)
> Sys.getenv('PATH') %>% str_split(';')
[[1]]
 [1] "C:\\Rtools\\bin"                                                         
 [2] "C:\\Program Files\\ImageMagick-7.0.7-Q16"                                
... other irrelevant path folders            
[30] "C:\\RBuildTools\\bin"                                                    
[31] "C:\\RBuildTools\\3.4\\mingw_64\\bin"                                     
[32] "C:\\RBuildTools\\3.4\\mingw_32\\bin" 

I think the issue is here, I have added the mingw_64 folders to the path, since they seem to include the compilers, but the folder structure of my RBuildTools installation is different from the Windows installation guide. As such I want to believe that it is all a matter of including the appropriate subfolders of the RBuildTools in PATH, but I am quite lost on this issue.

The errror dump.

Warning message:
running command 'make -f "C:/Users/e048366/DOCUME~1/R/R-34~1.3/etc/x64/Makeconf" -f "C:/Users/e048366/DOCUME~1/R/R-34~1.3/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file2b846af33b8d.dll" WIN=64 TCLBIN=64 OBJECTS="file2b846af33b8d.o"' had status 127 

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


Program source:
  1: 
  2: // includes from the plugin
  3: 
  4: 
  5: // user includes
  6: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.17.0
  7: 
  8: #include <stan/model/model_header.hpp>
  9: 
 10: namespace model2b8468eb269d_VAR2_namespace {
 11: 
 12: using std::istream;
 13: using std::string;
 14: using std::stringstream;
 15: using std::vector;
 16: using stan::io::dump;
 17: using stan::math::lgamma;
 18: using stan::model::prob_grad;
 19: using namespace stan::math;
 20: 
 21: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
 22: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
 23: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
 24: 
 25: static int current_statement_begin__;
 26: 
 27: stan::io::program_reader prog_reader__() {
 28:     stan::io::program_reader reader;
 29:     reader.add_event(0, 0, "start", "model2b8468eb269d_VAR2");
 30:     reader.add_event(17, 17, "end", "model2b8468eb269d_VAR2");
 31:     return reader;
 32: }
 33: 
 34: class model2b8468eb269d_VAR2 : public prob_grad {
 35: private:
 36:     int V;
 37:     int K;
 38:     matrix_d y;
 39: public:
 40:     model2b8468eb269d_VAR2(stan::io::var_context& context__,
 41:         std::ostream* pstream__ = 0)
 42:         : prob_grad(0) {
 43:         ctor_body(context__, 0, pstream__);
 44:     }
 45: 
 46:     model2b8468eb269d_VAR2(stan::io::var_context& context__,
 47:         unsigned int random_seed__,
 48:         std::ostream* pstream__ = 0)
 49:         : prob_grad(0) {
 50:         ctor_body(context__, random_seed__, pstream__);
 51:     }
 52: 
 53:     void ctor_body(stan::io::var_context& context__,
 54:                    unsigned int random_seed__,
 55:                    std::ostream* pstream__) {
 56:         boost::ecuyer1988 base_rng__ =
 57:           stan::services::util::create_rng(random_seed__, 0);
 58:         (void) base_rng__;  // suppress unused var warning
 59: 
 60:         current_statement_begin__ = -1;
 61: 
 62:         static const char* function__ = "model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2";
 63:         (void) function__;  // dummy to suppress unused var warning
 64:         size_t pos__;
 65:         (void) pos__;  // dummy to suppress unused var warning
 66:         std::vector<int> vals_i__;
 67:         std::vector<double> vals_r__;
 68:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 69:         (void) DUMMY_VAR__;  // suppress unused var warning
 70: 
 71:         // initialize member variables
 72:         try {
 73:             current_statement_begin__ = 2;
 74:             context__.validate_dims("data initialization", "V", "int", context__.to_vec());
 75:             V = int(0);
 76:             vals_i__ = context__.vals_i("V");
 77:             pos__ = 0;
 78:             V = vals_i__[pos__++];
 79:             current_statement_begin__ = 3;
 80:             context__.validate_dims("data initialization", "K", "int", context__.to_vec());
 81:             K = int(0);
 82:             vals_i__ = context__.vals_i("K");
 83:             pos__ = 0;
 84:             K = vals_i__[pos__++];
 85:             current_statement_begin__ = 4;
 86:             validate_non_negative_index("y", "V", V);
 87:             validate_non_negative_index("y", "K", K);
 88:             context__.validate_dims("data initialization", "y", "matrix_d", context__.to_vec(V,K));
 89:             validate_non_negative_index("y", "V", V);
 90:             validate_non_negative_index("y", "K", K);
 91:             y = matrix_d(static_cast<Eigen::VectorXd::Index>(V),static_cast<Eigen::VectorXd::Index>(K));
 92:             vals_r__ = context__.vals_r("y");
 93:             pos__ = 0;
 94:             size_t y_m_mat_lim__ = V;
 95:             size_t y_n_mat_lim__ = K;
 96:             for (size_t n_mat__ = 0; n_mat__ < y_n_mat_lim__; ++n_mat__) {
 97:                 for (size_t m_mat__ = 0; m_mat__ < y_m_mat_lim__; ++m_mat__) {
 98:                     y(m_mat__,n_mat__) = vals_r__[pos__++];
 99:                 }
100:             }
101: 
102:             // validate, data variables
103:             current_statement_begin__ = 2;
104:             check_greater_or_equal(function__,"V",V,0);
105:             current_statement_begin__ = 3;
106:             check_greater_or_equal(function__,"K",K,0);
107:             current_statement_begin__ = 4;
108:             // initialize data variables
109: 
110: 
111:             // validate transformed data
112: 
113:             // validate, set parameter ranges
114:             num_params_r__ = 0U;
115:             param_ranges_i__.clear();
116:             current_statement_begin__ = 7;
117:         validate_non_negative_index("A", "V", V);
118:             validate_non_negative_index("A", "V", V);
119:             num_params_r__ += V * V;
120:             current_statement_begin__ = 8;
121:             validate_non_negative_index("Sigma", "V", V);
122:             num_params_r__ += ((V * (V - 1)) / 2 + V);
123:         } catch (const std::exception& e) {
124:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
125:             // Next line prevents compiler griping about no return
126:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
127:         }
128:     }
129: 
130:     ~model2b8468eb269d_VAR2() { }
131: 
132: 
133:     void transform_inits(const stan::io::var_context& context__,
134:                          std::vector<int>& params_i__,
135:                          std::vector<double>& params_r__,
136:                          std::ostream* pstream__) const {
137:         stan::io::writer<double> writer__(params_r__,params_i__);
138:         size_t pos__;
139:         (void) pos__; // dummy call to supress warning
140:         std::vector<double> vals_r__;
141:         std::vector<int> vals_i__;
142: 
143:         if (!(context__.contains_r("A")))
144:             throw std::runtime_error("variable A missing");
145:         vals_r__ = context__.vals_r("A");
146:         pos__ = 0U;
147:         validate_non_negative_index("A", "V", V);
148:         validate_non_negative_index("A", "V", V);
149:         context__.validate_dims("initialization", "A", "matrix_d", context__.to_vec(V,V));
150:         matrix_d A(static_cast<Eigen::VectorXd::Index>(V),static_cast<Eigen::VectorXd::Index>(V));
151:         for (int j2__ = 0U; j2__ < V; ++j2__)
152:             for (int j1__ = 0U; j1__ < V; ++j1__)
153:                 A(j1__,j2__) = vals_r__[pos__++];
154:         try {
155:             writer__.matrix_lub_unconstrain(-(2),2,A);
156:         } catch (const std::exception& e) { 
157:             throw std::runtime_error(std::string("Error transforming variable A: ") + e.what());
158:         }
159: 
160:         if (!(context__.contains_r("Sigma")))
161:             throw std::runtime_error("variable Sigma missing");
162:         vals_r__ = context__.vals_r("Sigma");
163:         pos__ = 0U;
164:         validate_non_negative_index("Sigma", "V", V);
165:         validate_non_negative_index("Sigma", "V", V);
166:         context__.validate_dims("initialization", "Sigma", "matrix_d", context__.to_vec(V,V));
167:         matrix_d Sigma(static_cast<Eigen::VectorXd::Index>(V),static_cast<Eigen::VectorXd::Index>(V));
168:         for (int j2__ = 0U; j2__ < V; ++j2__)
169:             for (int j1__ = 0U; j1__ < V; ++j1__)
170:                 Sigma(j1__,j2__) = vals_r__[pos__++];
171:         try {
172:             writer__.cov_matrix_unconstrain(Sigma);
173:         } catch (const std::exception& e) { 
174:             throw std::runtime_error(std::string("Error transforming variable Sigma: ") + e.what());
175:         }
176: 
177:         params_r__ = writer__.data_r();
178:         params_i__ = writer__.data_i();
179:     }
180: 
181:     void transform_inits(const stan::io::var_context& context,
182:                          Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
183:                          std::ostream* pstream__) const {
184:       std::vector<double> params_r_vec;
185:       std::vector<int> params_i_vec;
186:       transform_inits(context, params_i_vec, params_r_vec, pstream__);
187:       params_r.resize(params_r_vec.size());
188:       for (int i = 0; i < params_r.size(); ++i)
189:         params_r(i) = params_r_vec[i];
190:     }
191: 
192: 
193:     template <bool propto__, bool jacobian__, typename T__>
194:     T__ log_prob(vector<T__>& params_r__,
195:                  vector<int>& params_i__,
196:                  std::ostream* pstream__ = 0) const {
197: 
198:         T__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
199:         (void) DUMMY_VAR__;  // suppress unused var warning
200: 
201:         T__ lp__(0.0);
202:         stan::math::accumulator<T__> lp_accum__;
203: 
204:         try {
205:             // model parameters
206:             stan::io::reader<T__> in__(params_r__,params_i__);
207: 
208:             Eigen::Matrix<T__,Eigen::Dynamic,Eigen::Dynamic>  A;
209:             (void) A;  // dummy to suppress unused var warning
210:             if (jacobian__)
211:                 A = in__.matrix_lub_constrain(-(2),2,V,V,lp__);
212:             else
213:                 A = in__.matrix_lub_constrain(-(2),2,V,V);
214: 
215:             Eigen::Matrix<T__,Eigen::Dynamic,Eigen::Dynamic>  Sigma;
216:             (void) Sigma;  // dummy to suppress unused var warning
217:             if (jacobian__)
218:                 Sigma = in__.cov_matrix_constrain(V,lp__);
219:             else
220:                 Sigma = in__.cov_matrix_constrain(V);
221: 
222: 
223:             // transformed parameters
224: 
225: 
226: 
227:             // validate transformed parameters
228: 
229:             const char* function__ = "validate transformed params";
230:             (void) function__;  // dummy to suppress unused var warning
231: 
232:             // model body
233: 
234:             current_statement_begin__ = 11;
235:             for (int k = 1; k <= V; ++k) {
236: 
237:                 current_statement_begin__ = 12;
238:                 for (int j = 1; j <= V; ++j) {
239: 
240:                     current_statement_begin__ = 13;
241:                     lp_accum__.add(normal_log<propto__>(get_base1(A,k,j,"A",1), 0, 1));
242:                 }
243:             }
244:             current_statement_begin__ = 15;
245:             for (int k = 2; k <= K; ++k) {
246:                 current_statement_begin__ = 16;
247:                 lp_accum__.add(multi_normal_log<propto__>(stan::model::rvalue(y, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_omni(), stan::model::nil_index_list())), "y"), multiply(stan::model::rvalue(y, stan::model::cons_list(stan::model::index_uni((k - 1)), stan::model::cons_list(stan::model::index_omni(), stan::model::nil_index_list())), "y"),A), Sigma));
248:             }
249: 
250:         } catch (const std::exception& e) {
251:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
252:             // Next line prevents compiler griping about no return
253:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
254:         }
255: 
256:         lp_accum__.add(lp__);
257:         return lp_accum__.sum();
258: 
259:     } // log_prob()
260: 
261:     template <bool propto, bool jacobian, typename T_>
262:     T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
263:                std::ostream* pstream = 0) const {
264:       std::vector<T_> vec_params_r;
265:       vec_params_r.reserve(params_r.size());
266:       for (int i = 0; i < params_r.size(); ++i)
267:         vec_params_r.push_back(params_r(i));
268:       std::vector<int> vec_params_i;
269:       return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
270:     }
271: 
272: 
273:     void get_param_names(std::vector<std::string>& names__) const {
274:         names__.resize(0);
275:         names__.push_back("A");
276:         names__.push_back("Sigma");
277:     }
278: 
279: 
280:     void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
281:         dimss__.resize(0);
282:         std::vector<size_t> dims__;
283:         dims__.resize(0);
284:         dims__.push_back(V);
285:         dims__.push_back(V);
286:         dimss__.push_back(dims__);
287:         dims__.resize(0);
288:         dims__.push_back(V);
289:         dims__.push_back(V);
290:         dimss__.push_back(dims__);
291:     }
292: 
293:     template <typename RNG>
294:     void write_array(RNG& base_rng__,
295:                      std::vector<double>& params_r__,
296:                      std::vector<int>& params_i__,
297:                      std::vector<double>& vars__,
298:                      bool include_tparams__ = true,
299:                      bool include_gqs__ = true,
300:                      std::ostream* pstream__ = 0) const {
301:         vars__.resize(0);
302:         stan::io::reader<double> in__(params_r__,params_i__);
303:         static const char* function__ = "model2b8468eb269d_VAR2_namespace::write_array";
304:         (void) function__;  // dummy to suppress unused var warning
305:         // read-transform, write parameters
306:         matrix_d A = in__.matrix_lub_constrain(-(2),2,V,V);
307:         matrix_d Sigma = in__.cov_matrix_constrain(V);
308:             for (int k_1__ = 0; k_1__ < V; ++k_1__) {
309:                 for (int k_0__ = 0; k_0__ < V; ++k_0__) {
310:                 vars__.push_back(A(k_0__, k_1__));
311:                 }
312:             }
313:             for (int k_1__ = 0; k_1__ < V; ++k_1__) {
314:                 for (int k_0__ = 0; k_0__ < V; ++k_0__) {
315:                 vars__.push_back(Sigma(k_0__, k_1__));
316:                 }
317:             }
318: 
319:         if (!include_tparams__) return;
320:         // declare and define transformed parameters
321:         double lp__ = 0.0;
322:         (void) lp__;  // dummy to suppress unused var warning
323:         stan::math::accumulator<double> lp_accum__;
324: 
325:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
326:         (void) DUMMY_VAR__;  // suppress unused var warning
327: 
328:         try {
329: 
330: 
331: 
332:             // validate transformed parameters
333: 
334:             // write transformed parameters
335: 
336:             if (!include_gqs__) return;
337:             // declare and define generated quantities
338: 
339: 
340: 
341:             // validate generated quantities
342: 
343:             // write generated quantities
344:         } catch (const std::exception& e) {
345:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
346:             // Next line prevents compiler griping about no return
347:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
348:         }
349:     }
350: 
351:     template <typename RNG>
352:     void write_array(RNG& base_rng,
353:                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
354:                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
355:                      bool include_tparams = true,
356:                      bool include_gqs = true,
357:                      std::ostream* pstream = 0) const {
358:       std::vector<double> params_r_vec(params_r.size());
359:       for (int i = 0; i < params_r.size(); ++i)
360:         params_r_vec[i] = params_r(i);
361:       std::vector<double> vars_vec;
362:       std::vector<int> params_i_vec;
363:       write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
364:       vars.resize(vars_vec.size());
365:       for (int i = 0; i < vars.size(); ++i)
366:         vars(i) = vars_vec[i];
367:     }
368: 
369:     static std::string model_name() {
370:         return "model2b8468eb269d_VAR2";
371:     }
372: 
373: 
374:     void constrained_param_names(std::vector<std::string>& param_names__,
375:                                  bool include_tparams__ = true,
376:                                  bool include_gqs__ = true) const {
377:         std::stringstream param_name_stream__;
378:         for (int k_1__ = 1; k_1__ <= V; ++k_1__) {
379:             for (int k_0__ = 1; k_0__ <= V; ++k_0__) {
380:                 param_name_stream__.str(std::string());
381:                 param_name_stream__ << "A" << '.' << k_0__ << '.' << k_1__;
382:                 param_names__.push_back(param_name_stream__.str());
383:             }
384:         }
385:         for (int k_1__ = 1; k_1__ <= V; ++k_1__) {
386:             for (int k_0__ = 1; k_0__ <= V; ++k_0__) {
387:                 param_name_stream__.str(std::string());
388:                 param_name_stream__ << "Sigma" << '.' << k_0__ << '.' << k_1__;
389:                 param_names__.push_back(param_name_stream__.str());
390:             }
391:         }
392: 
393:         if (!include_gqs__ && !include_tparams__) return;
394: 
395:         if (!include_gqs__) return;
396:     }
397: 
398: 
399:     void unconstrained_param_names(std::vector<std::string>& param_names__,
400:                                    bool include_tparams__ = true,
401:                                    bool include_gqs__ = true) const {
402:         std::stringstream param_name_stream__;
403:         for (int k_1__ = 1; k_1__ <= V; ++k_1__) {
404:             for (int k_0__ = 1; k_0__ <= V; ++k_0__) {
405:                 param_name_stream__.str(std::string());
406:                 param_name_stream__ << "A" << '.' << k_0__ << '.' << k_1__;
407:                 param_names__.push_back(param_name_stream__.str());
408:             }
409:         }
410:         for (int k_0__ = 1; k_0__ <= (V + ((V * (V - 1)) / 2)); ++k_0__) {
411:             param_name_stream__.str(std::string());
412:             param_name_stream__ << "Sigma" << '.' << k_0__;
413:             param_names__.push_back(param_name_stream__.str());
414:         }
415: 
416:         if (!include_gqs__ && !include_tparams__) return;
417: 
418:         if (!include_gqs__) return;
419:     }
420: 
421: }; // model
422: 
423: }
424: 
425: typedef model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2 stan_model;
426: 
427: #include <rstan/rstaninc.hpp>
428: /**
429:  * Define Rcpp Module to expose stan_fit's functions to R.
430:  */
431: RCPP_MODULE(stan_fit4model2b8468eb269d_VAR2_mod){
432:   Rcpp::class_<rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2,
433:                boost::random::ecuyer1988> >("stan_fit4model2b8468eb269d_VAR2")
434:     // .constructor<Rcpp::List>()
435:     .constructor<SEXP, SEXP, SEXP>()
436:     // .constructor<SEXP, SEXP>()
437:     .method("call_sampler",
438:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::call_sampler)
439:     .method("param_names",
440:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::param_names)
441:     .method("param_names_oi",
442:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::param_names_oi)
443:     .method("param_fnames_oi",
444:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::param_fnames_oi)
445:     .method("param_dims",
446:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::param_dims)
447:     .method("param_dims_oi",
448:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::param_dims_oi)
449:     .method("update_param_oi",
450:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::update_param_oi)
451:     .method("param_oi_tidx",
452:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::param_oi_tidx)
453:     .method("grad_log_prob",
454:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::grad_log_prob)
455:     .method("log_prob",
456:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::log_prob)
457:     .method("unconstrain_pars",
458:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::unconstrain_pars)
459:     .method("constrain_pars",
460:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::constrain_pars)
461:     .method("num_pars_unconstrained",
462:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::num_pars_unconstrained)
463:     .method("unconstrained_param_names",
464:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::unconstrained_param_names)
465:     .method("constrained_param_names",
466:             &rstan::stan_fit<model2b8468eb269d_VAR2_namespace::model2b8468eb269d_VAR2, boost::random::ecuyer1988>::constrained_param_names)
467:     ;
468: }
469: 
470: // declarations
471: extern "C" {
472: SEXP file2b846af33b8d( ) ;
473: }
474: 
475: // definition
476: 
477: SEXP file2b846af33b8d(  ){
478:  return Rcpp::wrap("VAR2");
479: }
480: 
481: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! Warning message:
running command 'make -f "C:/Users/e048366/DOCUME~1/R/R-34~1.3/etc/x64/Makeconf" -f "C:/Users/e048366/DOCUME~1/R/R-34~1.3/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file2b846af33b8d.dll" WIN=64 TCLBIN=64 OBJECTS="file2b846af33b8d.o"' had status 127 
In addition: Warning message:
running command 'C:/Users/e048366/DOCUME~1/R/R-34~1.3/bin/x64/R CMD SHLIB file2b846af33b8d.cpp 2> file2b846af33b8d.cpp.err.txt' had status 1 
4

1 回答 1

2

感谢用户Dirik Eddelbuettelhadley的评论,我能够查明问题所在。它在我的路径设置中。我遵循 RTools 的默认安装,将安装文件夹设置为 RBuildTools。但是,无论我在安装期间或之后如何编辑 PATH,R 都将我的路径变量设置为不存在的 RTools 文件夹。将 RTools 安装到名为 RTools 的文件夹中解决了这个问题。

于 2018-01-19T15:25:50.170 回答