# Problem with C++ Compiler on Mac

**URL:** <https://discourse.mc-stan.org/t/problem-with-c-compiler-on-mac/6221>\
**Category:** RStan\
**Created:** [October 26, 2018, 11:15pm UTC](https://discourse.mc-stan.org/t/problem-with-c-compiler-on-mac/6221 "2018-10-26T23:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![waterbottles](https://avatars.discourse-cdn.com/v4/letter/w/ac91a4/32.png) [@waterbottles](https://discourse.mc-stan.org/u/waterbottles)\
**Post date:** [October 26, 2018, 11:15pm UTC](https://discourse.mc-stan.org/t/problem-with-c-compiler-on-mac/6221/1 "2018-10-26T23:15:43Z")

</div>

I’m having a problem getting rstan to work due to an issue with the C++ compiler. I’m running OS X 10.14 Mojave with Xcode 10.0, clang 6.0, R 3.5.1, Rstudio 1.1.456, Rstan 2.18.1, gfortran 6.1.

I’ve run the exact same code on colleagues’ computers who have followed the same steps to install the requisite packages etc and it worked fine for them. I’m at a loss as to what to do.

My model is very basic:

data{  
int N;  
real y[N];  
}

parameters{  
real mu;  
real\<lower=0\> sigma;  
}

model{  
y ~ normal(mu, sigma);  
}

When I try to call stan, I get the following error:

> mod1fit ← stan(“mod1.stan”, data=list(N=N, y=y), iter=1000, warmup=500, chains=3)  
> In file included from file231a5cb7c026.cpp:8:  
> In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/src/stan/model/model\_header.hpp:4:  
> In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math.hpp:4:  
> In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:4:  
> In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core.hpp:4:  
> In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4:  
> In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/memory/stack\_alloc.hpp:8:  
> In file included from /usr/local/clang6/include/c++/v1/cstdlib:86:  
> /usr/local/clang6/include/c++/v1/stdlib.h:94:15: fatal error: ‘stdlib.h’ file not found  
> #include\_next \<stdlib.h\>  
> ^ ~~~~~~~~~  
> 1 error generated.  
> make: \*\*\* [file231a5cb7c026.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// Code generated by Stan version 2.18.0  
7:  
8: #include \<stan/model/model\_header.hpp\>  
9:  
10: namespace model231a3d907a56\_mod1\_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: static int current\_statement\_begin\_\_;  
22:  
23: stan::io::program\_reader prog\_reader\_\_() {  
24: stan::io::program\_reader reader;  
25: reader.add\_event(0, 0, “start”, “model231a3d907a56\_mod1”);  
26: reader.add\_event(15, 13, “end”, “model231a3d907a56\_mod1”);  
27: return reader;  
28: }  
29:  
30: class model231a3d907a56\_mod1 : public prob\_grad {  
31: private:  
32: int N;  
33: vector y;  
34: public:  
35: model231a3d907a56\_mod1(stan::io::var\_context& context\_\_,  
36: std::ostream\* pstream\_\_ = 0)  
37: : prob\_grad(0) {  
38: ctor\_body(context\_\_, 0, pstream\_\_);  
39: }  
40:  
41: model231a3d907a56\_mod1(stan::io::var\_context& context\_\_,  
42: unsigned int random\_seed\_\_,  
43: std::ostream\* pstream\_\_ = 0)  
44: : prob\_grad(0) {  
45: ctor\_body(context\_\_, random\_seed\_\_, pstream\_\_);  
46: }  
47:  
48: void ctor\_body(stan::io::var\_context& context\_\_,  
49: unsigned int random\_seed\_\_,  
50: std::ostream\* pstream\_\_) {  
51: typedef double local\_scalar\_t\_\_;  
52:  
53: boost::ecuyer1988 base\_rng\_\_ =  
54: stan::services::util::create\_rng(random\_seed\_\_, 0);  
55: (void) base\_rng\_\_; // suppress unused var warning  
56:  
57: current\_statement\_begin\_\_ = -1;  
58:  
59: static const char\* function\_\_ = “model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1”;  
60: (void) function\_\_; // dummy to suppress unused var warning  
61: size\_t pos\_\_;  
62: (void) pos\_\_; // dummy to suppress unused var warning  
63: std::vector vals\_i\_\_;  
64: std::vector vals\_r\_\_;  
65: local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
66: (void) DUMMY\_VAR\_\_; // suppress unused var warning  
67:  
68: // initialize member variables  
69: try {  
70: current\_statement\_begin\_\_ = 2;  
71: context\_\_.validate\_dims(“data initialization”, “N”, “int”, context\_\_.to\_vec());  
72: N = int(0);  
73: vals\_i\_\_ = context\_\_.vals\_i(“N”);  
74: pos\_\_ = 0;  
75: N = vals\_i\_\_[pos\_\_++];  
76: current\_statement\_begin\_\_ = 3;  
77: validate\_non\_negative\_index(“y”, “N”, N);  
78: context\_\_.validate\_dims(“data initialization”, “y”, “double”, context\_\_.to\_vec(N));  
79: validate\_non\_negative\_index(“y”, “N”, N);  
80: y = std::vector(N,double(0));  
81: vals\_r\_\_ = context\_\_.vals\_r(“y”);  
82: pos\_\_ = 0;  
83: size\_t y\_limit\_0\_\_ = N;  
84: for (size\_t i\_0\_\_ = 0; i\_0\_\_ \< y\_limit\_0\_\_; ++i\_0\_\_) {  
85: y[i\_0\_\_] = vals\_r\_\_[pos\_\_++];  
86: }  
87:  
88: // validate, data variables  
89: current\_statement\_begin\_\_ = 2;  
90: current\_statement\_begin\_\_ = 3;  
91: // initialize data variables  
92:  
93:  
94: // validate transformed data  
95:  
96: // validate, set parameter ranges  
97: num\_params\_r\_\_ = 0U;  
98: param\_ranges\_i\_\_.clear();  
99: current\_statement\_begin\_\_ = 7;  
100: ++num\_params\_r\_\_;  
101: current\_statement\_begin\_\_ = 8;  
102: ++num\_params\_r\_\_;  
103: } catch (const std::exception& e) {  
104: stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
105: // Next line prevents compiler griping about no return  
106: throw std::runtime\_error(“\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG _");  
107: }  
108: }  
109:  
110: ~model231a3d907a56\_mod1() { }  
111:  
112:  
113: void transform\_inits(const stan::io::var\_context& context\_\_,  
114: std::vector& params\_i\_\_,  
115: std::vector& params\_r\_\_,  
116: std::ostream pstream\_\_) const {  
117: stan::io::writer writer\_\_(params\_r\_\_,params\_i\_\_);  
118: size\_t pos\_\_;  
119: (void) pos\_\_; // dummy call to supress warning  
120: std::vector vals\_r\_\_;  
121: std::vector vals\_i\_\_;  
122:  
123: if (!(context\_\_.contains\_r(“mu”)))  
124: throw std::runtime\_error(“variable mu missing”);  
125: vals\_r\_\_ = context\_\_.vals\_r(“mu”);  
126: pos\_\_ = 0U;  
127: context\_\_.validate\_dims(“initialization”, “mu”, “double”, context\_\_.to\_vec());  
128: double mu(0);  
129: mu = vals\_r\_\_[pos\_\_++];  
130: try {  
131: writer\_\_.scalar\_unconstrain(mu);  
132: } catch (const std::exception& e) {  
133: throw std::runtime\_error(std::string("Error transforming variable mu: ") + e.what());  
134: }  
135:  
136: if (!(context\_\_.contains\_r(“sigma”)))  
137: throw std::runtime\_error(“variable sigma missing”);  
138: vals\_r\_\_ = context\_\_.vals\_r(“sigma”);  
139: pos\_\_ = 0U;  
140: context\_\_.validate\_dims(“initialization”, “sigma”, “double”, context\_\_.to\_vec());  
141: double sigma(0);  
142: sigma = vals\_r\_\_[pos\_\_++];  
143: try {  
144: writer\_\_.scalar\_lb\_unconstrain(0,sigma);  
145: } catch (const std::exception& e) {  
146: throw std::runtime\_error(std::string("Error transforming variable sigma: ") + e.what());  
147: }  
148:  
149: params\_r\_\_ = writer\_\_.data\_r();  
150: params\_i\_\_ = writer\_\_.data\_i();  
151: }  
152:  
153: void transform\_inits(const stan::io::var\_context& context,  
154: Eigen::Matrix\<double,Eigen::Dynamic,1\>& params\_r,  
155: std::ostream pstream\_\_) const {  
156: std::vector params\_r\_vec;  
157: std::vector params\_i\_vec;  
158: transform\_inits(context, params\_i\_vec, params\_r\_vec, pstream\_\_);  
159: params\_r.resize(params\_r\_vec.size());  
160: for (int i = 0; i \< params\_r.size(); ++i)  
161: params\_r(i) = params\_r\_vec[i];  
162: }  
163:  
164:  
165: template \<bool propto\_\_, bool jacobian\_\_, typename T\_\_\>  
166: T\_\_ log\_prob(vector\<T\_\_\>& params\_r\_\_,  
167: vector& params\_i\_\_,  
168: std::ostream_ pstream\_\_ = 0) const {  
169:  
170: typedef T\_\_ local\_scalar\_t\_\_;  
171:  
172: local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
173: (void) DUMMY\_VAR\_\_; // suppress unused var warning  
174:  
175: T\_\_ lp\_\_(0.0);  
176: stan::math::accumulator\<T\_\_\> lp\_accum\_\_;  
177:  
178: try {  
179: // model parameters  
180: stan::io::reader\<local\_scalar\_t\_\_\> in\_\_(params\_r\_\_,params\_i\_\_);  
181:  
182: local\_scalar\_t\_\_ mu;  
183: (void) mu; // dummy to suppress unused var warning  
184: if (jacobian\_\_)  
185: mu = in\_\_.scalar\_constrain(lp\_\_);  
186: else  
187: mu = in\_\_.scalar\_constrain();  
188:  
189: local\_scalar\_t\_\_ sigma;  
190: (void) sigma; // dummy to suppress unused var warning  
191: if (jacobian\_\_)  
192: sigma = in\_\_.scalar\_lb\_constrain(0,lp\_\_);  
193: else  
194: sigma = in\_\_.scalar\_lb\_constrain(0);  
195:  
196:  
197: // transformed parameters  
198:  
199:  
200:  
201: // validate transformed parameters  
202:  
203: const char\* function\_\_ = “validate transformed params”;  
204: (void) function\_\_; // dummy to suppress unused var warning  
205:  
206: // model body  
207:  
208: current\_statement\_begin\_\_ = 12;  
209: lp\_accum\_\_.add(normal\_log\<propto\_\_\>(y, mu, sigma));  
210:  
211: } catch (const std::exception& e) {  
212: stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
213: // Next line prevents compiler griping about no return  
214: throw std::runtime\_error(”\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG _");  
215: }  
216:  
217: lp\_accum\_\_.add(lp\_\_);  
218: return lp\_accum\_\_.sum();  
219:  
220: } // log\_prob()  
221:  
222: template \<bool propto, bool jacobian, typename T\_\>  
223: T\_ log\_prob(Eigen::Matrix\<T\_,Eigen::Dynamic,1\>& params\_r,  
224: std::ostream pstream = 0) const {  
225: std::vector\<T\_\> vec\_params\_r;  
226: vec\_params\_r.reserve(params\_r.size());  
227: for (int i = 0; i \< params\_r.size(); ++i)  
228: vec\_params\_r.push\_back(params\_r(i));  
229: std::vector vec\_params\_i;  
230: return log\_prob\<propto,jacobian,T\_\>(vec\_params\_r, vec\_params\_i, pstream);  
231: }  
232:  
233:  
234: void get\_param\_names(std::vectorstd::string& names\_\_) const {  
235: names\_\_.resize(0);  
236: names\_\_.push\_back(“mu”);  
237: names\_\_.push\_back(“sigma”);  
238: }  
239:  
240:  
241: void get\_dims(std::vector\<std::vector\<size\_t\> \>& dimss\_\_) const {  
242: dimss\_\_.resize(0);  
243: std::vector\<size\_t\> dims\_\_;  
244: dims\_\_.resize(0);  
245: dimss\_\_.push\_back(dims\_\_);  
246: dims\_\_.resize(0);  
247: dimss\_\_.push\_back(dims\_\_);  
248: }  
249:  
250: template   
251: void write\_array(RNG& base\_rng\_\_,  
252: std::vector& params\_r\_\_,  
253: std::vector& params\_i\_\_,  
254: std::vector& vars\_\_,  
255: bool include\_tparams\_\_ = true,  
256: bool include\_gqs\_\_ = true,  
257: std::ostream pstream\_\_ = 0) const {  
258: typedef double local\_scalar\_t\_\_;  
259:  
260: vars\_\_.resize(0);  
261: stan::io::reader\<local\_scalar\_t\_\_\> in\_\_(params\_r\_\_,params\_i\_\_);  
262: static const char_ function\_\_ = “model231a3d907a56\_mod1\_namespace::write\_array”;  
263: (void) function\_\_; // dummy to suppress unused var warning  
264: // read-transform, write parameters  
265: double mu = in\_\_.scalar\_constrain();  
266: double sigma = in\_\_.scalar\_lb\_constrain(0);  
267: vars\_\_.push\_back(mu);  
268: vars\_\_.push\_back(sigma);  
269:  
270: // declare and define transformed parameters  
271: double lp\_\_ = 0.0;  
272: (void) lp\_\_; // dummy to suppress unused var warning  
273: stan::math::accumulator lp\_accum\_\_;  
274:  
275: local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
276: (void) DUMMY\_VAR\_\_; // suppress unused var warning  
277:  
278: try {  
279:  
280:  
281:  
282: // validate transformed parameters  
283:  
284: // write transformed parameters  
285: if (include\_tparams\_\_) {  
286: }  
287: if (!include\_gqs\_\_) return;  
288: // declare and define generated quantities  
289:  
290:  
291:  
292: // validate generated quantities  
293:  
294: // write generated quantities  
295: } catch (const std::exception& e) {  
296: stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
297: // Next line prevents compiler griping about no return  
298: throw std::runtime\_error("\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG **_");  
299: }  
300: }  
301:  
302: template   
303: void write\_array(RNG& base\_rng,  
304: Eigen::Matrix\<double,Eigen::Dynamic,1\>& params\_r,  
305: Eigen::Matrix\<double,Eigen::Dynamic,1\>& vars,  
306: bool include\_tparams = true,  
307: bool include\_gqs = true,  
308: std::ostream_ pstream = 0) const {  
309: std::vector params\_r\_vec(params\_r.size());  
310: for (int i = 0; i \< params\_r.size(); ++i)  
311: params\_r\_vec[i] = params\_r(i);  
312: std::vector vars\_vec;  
313: std::vector params\_i\_vec;  
314: write\_array(base\_rng,params\_r\_vec,params\_i\_vec,vars\_vec,include\_tparams,include\_gqs,pstream);  
315: vars.resize(vars\_vec.size());  
316: for (int i = 0; i \< vars.size(); ++i)  
317: vars(i) = vars\_vec[i];  
318: }  
319:  
320: static std::string model\_name() {  
321: return “model231a3d907a56\_mod1”;  
322: }  
323:  
324:  
325: void constrained\_param\_names(std::vectorstd::string& param\_names\_\_,  
326: bool include\_tparams\_\_ = true,  
327: bool include\_gqs\_\_ = true) const {  
328: std::stringstream param\_name\_stream\_\_;  
329: param\_name\_stream\_\_.str(std::string());  
330: param\_name\_stream\_\_ \<\< “mu”;  
331: param\_names\_\_.push\_back(param\_name\_stream\_\_.str());  
332: param\_name\_stream\_\_.str(std::string());  
333: param\_name\_stream\_\_ \<\< “sigma”;  
334: param\_names\_\_.push\_back(param\_name\_stream\_\_.str());  
335:  
336: if (!include\_gqs\_\_ && !include\_tparams\_\_) return;  
337:  
338: if (include\_tparams\_\_) {  
339: }  
340:  
341:  
342: if (!include\_gqs\_\_) return;  
343: }  
344:  
345:  
346: void unconstrained\_param\_names(std::vectorstd::string& param\_names\_\_,  
347: bool include\_tparams\_\_ = true,  
348: bool include\_gqs\_\_ = true) const {  
349: std::stringstream param\_name\_stream\_\_;  
350: param\_name\_stream\_\_.str(std::string());  
351: param\_name\_stream\_\_ \<\< “mu”;  
352: param\_names\_\_.push\_back(param\_name\_stream\_\_.str());  
353: param\_name\_stream\_\_.str(std::string());  
354: param\_name\_stream\_\_ \<\< “sigma”;  
355: param\_names\_\_.push\_back(param\_name\_stream\_\_.str());  
356:  
357: if (!include\_gqs\_\_ && !include\_tparams\_\_) return;  
358:  
359: if (include\_tparams\_\_) {  
360: }  
361:  
362:  
363: if (!include\_gqs\_\_) return;  
364: }  
365:  
366: }; // model  
367:  
368: }  
369:  
370: typedef model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1 stan\_model;  
371:  
372: #include \<rstan/rstaninc.hpp\>  
373: /**  
374: \* Define Rcpp Module to expose stan\_fit’s functions to R.  
375: \*/  
376: RCPP\_MODULE(stan\_fit4model231a3d907a56\_mod1\_mod){  
377: Rcpp::class\_\<rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1,  
378: boost::random::ecuyer1988\> \>(“stan\_fit4model231a3d907a56\_mod1”)  
379: // .constructorRcpp::List()  
380: .constructor\<SEXP, SEXP, SEXP\>()  
381: // .constructor\<SEXP, SEXP\>()  
382: .method(“call\_sampler”,  
383: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::call\_sampler)  
384: .method(“param\_names”,  
385: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::param\_names)  
386: .method(“param\_names\_oi”,  
387: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::param\_names\_oi)  
388: .method(“param\_fnames\_oi”,  
389: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::param\_fnames\_oi)  
390: .method(“param\_dims”,  
391: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::param\_dims)  
392: .method(“param\_dims\_oi”,  
393: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::param\_dims\_oi)  
394: .method(“update\_param\_oi”,  
395: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::update\_param\_oi)  
396: .method(“param\_oi\_tidx”,  
397: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::param\_oi\_tidx)  
398: .method(“grad\_log\_prob”,  
399: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::grad\_log\_prob)  
400: .method(“log\_prob”,  
401: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::log\_prob)  
402: .method(“unconstrain\_pars”,  
403: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::unconstrain\_pars)  
404: .method(“constrain\_pars”,  
405: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::constrain\_pars)  
406: .method(“num\_pars\_unconstrained”,  
407: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::num\_pars\_unconstrained)  
408: .method(“unconstrained\_param\_names”,  
409: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::unconstrained\_param\_names)  
410: .method(“constrained\_param\_names”,  
411: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::constrained\_param\_names)  
412: .method(“standalone\_gqs”,  
413: &rstan::stan\_fit\<model231a3d907a56\_mod1\_namespace::model231a3d907a56\_mod1, boost::random::ecuyer1988\>::standalone\_gqs)  
414: ;  
415: }  
416:  
417: // declarations  
418: extern “C” {  
419: SEXP file231a5cb7c026( ) ;  
420: }  
421:  
422: // definition  
423:  
424: SEXP file231a5cb7c026( ){  
425: return Rcpp::wrap(“mod1”);  
426: }  
427:  
428:  
Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! In file included from file231a5cb7c026.cpp:8:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/src/stan/model/model\_header.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/memory/stack\_alloc.hpp:8:  
In file included from /usr/local/clang6/include/c++/v1/cstdlib:86:  
/usr/lo  
In addition: Warning message:  
In system(cmd, intern = !verbose) :  
running command ‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file231a5cb7c026.cpp 2\> file231a5cb7c026.cpp.err.txt’ had status 1

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 26, 2018, 11:28pm UTC](https://discourse.mc-stan.org/t/problem-with-c-compiler-on-mac/6221/2 "2018-10-26T23:28:36Z")

</div>

This has come up a couple of times. Are you using Anaconda? If so, the first link here may help.

> [@Compilation error on Mac](https://discourse.mc-stan.org/t/compilation-error-on-mac/5933/11):
>
> You are going to need to add -isystem /usr/include to CXX14FLAGS in your ~/.R/Makevars file and then try again. Something else will inevitably be missing, so add its directory with another -isystem thing. Repeat. Or setup your R environment outside of Conda.

Also, maybe

> [@RStan install problem on Mac (Nojave)](https://discourse.mc-stan.org/t/rstan-install-problem-on-mac-nojave/6022/10):
>
> I solved the problem. Just for the next person who runs into this problem, I wanted to document my failures. I installed xcode, deleted my R install and RStudio, and reinstalled these and then started the rstan install from scratch, following the steps laid out on [mc-stan.org](http://mc-stan.org). Then I got a new error message: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! In file included from file10025f51dc6d.cpp:3: In file inclu…

---

<div class="post-metadata">

**Author:** ![waterbottles](https://avatars.discourse-cdn.com/v4/letter/w/ac91a4/32.png) [@waterbottles](https://discourse.mc-stan.org/u/waterbottles)\
**Post date:** [October 27, 2018, 7:08pm UTC](https://discourse.mc-stan.org/t/problem-with-c-compiler-on-mac/6221/3 "2018-10-27T19:08:23Z")

</div>

thanks, i followed your advice, and when I went to edit it I realized that for some reason R wasn’t generating a Makevars file, so I manually created one and now everything is working fine.
