Mac OS X Rstan 2.2 broken with g++? clang++ seems to be fine.

192 views
Skip to first unread message

Richard McElreath

unread,
Feb 15, 2014, 5:30:10 PM2/15/14
to stan-...@googlegroups.com
I know people have been seeing this compile problem with RStan 2.2 (and began with RStan 2.1.1) on some Macs. Several of my students have been experiencing this issue, which is how it came to my attention. The pattern is that RStan compiles fine, but when compiling a model, it throws a messy error that begins with

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created!

It goes on for a while. I'll attach a full example as a text file. (Top of file has the relevant g++ -v output.)

I finally had a chance to sit down and try to isolate the issue. I think the problem is isolated to g++ 4.2.x, as I have been able to fix it by using clang++ to build Rstan, both under 10.7.x and 10.8.x (I dare not install 10.9, as everyone says it's evil).

So provided one has clang installed, all that's needed to fix the problem is to edit ~/.R/Makevars to include:

CXX = clang++

Then remove RStan and recompile. 

If this does indeed fix it for everyone, then maybe not worth fixing, as clang is available for everyone. But it is definitely worth putting a big flashing signal on RStan wiki about it, so everyone adds CXX=clang++ to their Makevars.
rstan22_mac_g++_error.txt

Ben Goodrich

unread,
Feb 15, 2014, 5:56:21 PM2/15/14
to stan-...@googlegroups.com
It is a known issue with Rcpp that will probably be fixed soon, so I haven't spent much time trying to work around it on the rstan side. Even if it weren't broken, I can't imagine why someone would actively want to use the (llvm-)g++ 4.2.x that comes with Xcode, even though it is the default used by R on Macs. It is basically just the llvm frontend with a 2007 version of the g++ library, which isn't tested much by Boost or Eigen or Stan. If I had a Mac, I would just use llvm / clang / libc++. My mostly Mac-using students are going to be installing RStan soon, and I am not planning to deal with (llvm-)g++ 4.2.x at all.

Ben

Richard McElreath

unread,
Feb 15, 2014, 6:27:56 PM2/15/14
to stan-...@googlegroups.com
I'd vote for RStan forcing clang++ in Makevars, if that wouldn't cause any others issues.

Xiaowei Zhang

unread,
Feb 15, 2014, 7:37:40 PM2/15/14
to stan-...@googlegroups.com
Second this. I had the same problem and it was resolved by your suggestion. Thanks!

在 2014年2月16日星期日UTC+8上午6时30分10秒,Richard McElreath写道:

Bob Carpenter

unread,
Feb 16, 2014, 11:19:00 AM2/16/14
to stan-...@googlegroups.com
That would be great if it'll work cross platform. For
instance, does RTools for Windows include clang++?

It's soooo much faster to compile on the Mac (though I
think the more recent Xcode on the Mac may just be binding
g++ to clang++ in a way that's still left me confused).

- Bob
> --
> You received this message because you are subscribed to the Google Groups "stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Ben Goodrich

unread,
Feb 16, 2014, 11:21:28 AM2/16/14
to stan-...@googlegroups.com
On Sunday, February 16, 2014 11:19:00 AM UTC-5, Bob Carpenter wrote:
That would be great if it'll work cross platform.  For
instance, does RTools for Windows include clang++?

No. And to install clang++ on Windows, you basically have to have mingw headers anyway.

Ben

Ben Goodrich

unread,
Mar 14, 2014, 12:56:06 PM3/14/14
to stan-...@googlegroups.com
On Saturday, February 15, 2014 5:56:21 PM UTC-5, Ben Goodrich wrote:
It is a known issue with Rcpp that will probably be fixed soon, so I haven't spent much time trying to work around it on the rstan side. Even if it weren't broken, I can't imagine why someone would actively want to use the (llvm-)g++ 4.2.x that comes with Xcode, even though it is the default used by R on Macs. It is basically just the llvm frontend with a 2007 version of the g++ library, which isn't tested much by Boost or Eigen or Stan. If I had a Mac, I would just use llvm / clang / libc++. My mostly Mac-using students are going to be installing RStan soon, and I am not planning to deal with (llvm-)g++ 4.2.x at all.

Apparently, rstan is still unable to compile models with (llvm-)g++ 4.2.x with Rcpp 0.11. Although, you should still be able to install rstan with (llvm-)g++ 4.2 models with clang++. And you might be able to install rstan with clang++ on a Mac now, but I would need somebody with a Mac to verify.

Ben

Jiqiang Guo

unread,
Mar 16, 2014, 6:49:28 PM3/16/14
to stan-...@googlegroups.com
I think it is fine for (llvm-)g++4.2.1 to install rstan and compile models using the newly released Rcpp 0.11.1

Jiqiang 


--
You received this message because you are subscribed to the Google Groups "stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben Goodrich

unread,
Mar 16, 2014, 8:38:18 PM3/16/14
to stan-...@googlegroups.com
On Sunday, March 16, 2014 6:49:28 PM UTC-4, Jiqiang Guo wrote:
I think it is fine for (llvm-)g++4.2.1 to install rstan and compile models using the newly released Rcpp 0.11.1

For me, the models wouldn't compile with llvm-g++-4.2 and Rcpp 0.11.1, but that is the Linux version of llvm-g++-4.2 rather than the Mac version. Either way, the models should compile with clang++.

Ben
Reply all
Reply to author
Forward
0 new messages