'lvm-g++-4.2: command not found' error after installing XCode 5.0 on Mac OS 10.8.5

1,793 views
Skip to first unread message

Dale

unread,
Oct 17, 2013, 5:16:05 PM10/17/13
to stan-...@googlegroups.com

Hi - I'm attempting to install rstan on Mac OS 10.8.5.  I installed XCode 5.0 and Command Line Tools.

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

When I run the suggested code to test the C++ compiler ...

I get the appended error message.

Suggestions?  Thanks.  --Dale

/bin/sh: llvm-g++-4.2: command not found
make: *** [file9ec1ba6fc12.o] Error 127

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

Program source:
  1: 
  2: // includes from the plugin
  3: 
  4: #include <Rcpp.h>
  5: 
  6: 
  7: #ifndef BEGIN_RCPP
  8: #define BEGIN_RCPP
  9: #endif
 10: 
 11: #ifndef END_RCPP
 12: #define END_RCPP
 13: #endif
 14: 
 15: using namespace Rcpp;
 16: 
 17: 
 18: // user includes
 19: 
 20: 
 21: // declarations
 22: extern "C" {
 23: SEXP file9ec1ba6fc12( ) ;
 24: }
 25: 
 26: // definition
 27: 
 28: SEXP file9ec1ba6fc12(  ){
 29: BEGIN_RCPP
 30:  
 31:   std::vector<std::string> s; 
 32:   s.push_back("hello");
 33:   s.push_back("world");
 34:   return Rcpp::wrap(s);
 35: 
 36: END_RCPP
 37: }
 38: 
 39: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! /bin/sh: llvm-g++-4.2: command not found
make: *** [file9ec1ba6fc12.o] Error 127
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file9ec1ba6fc12.cpp 2> file9ec1ba6fc12.cpp.err.txt' had status 1 
> cat(hellofun(), '\n') 
Error in cat(hellofun(), "\n") : could not find function "hellofun"


/bin/sh: llvm-g++-4.2: command not found
make: *** [file9ec1ba6fc12.o] Error 127

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

Program source:
  1: 
  2: // includes from the plugin
  3: 
  4: #include <Rcpp.h>
  5: 
  6: 
  7: #ifndef BEGIN_RCPP
  8: #define BEGIN_RCPP
  9: #endif
 10: 
 11: #ifndef END_RCPP
 12: #define END_RCPP
 13: #endif
 14: 
 15: using namespace Rcpp;
 16: 
 17: 
 18: // user includes
 19: 
 20: 
 21: // declarations
 22: extern "C" {
 23: SEXP file9ec1ba6fc12( ) ;
 24: }
 25: 
 26: // definition
 27: 
 28: SEXP file9ec1ba6fc12(  ){
 29: BEGIN_RCPP
 30:  
 31:   std::vector<std::string> s; 
 32:   s.push_back("hello");
 33:   s.push_back("world");
 34:   return Rcpp::wrap(s);
 35: 
 36: END_RCPP
 37: }
 38: 
 39: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! /bin/sh: llvm-g++-4.2: command not found
make: *** [file9ec1ba6fc12.o] Error 127
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file9ec1ba6fc12.cpp 2> file9ec1ba6fc12.cpp.err.txt' had status 1 
> cat(hellofun(), '\n') 
Error in cat(hellofun(), "\n") : could not find function "hellofun"

Bob Carpenter

unread,
Oct 17, 2013, 5:24:25 PM10/17/13
to stan-...@googlegroups.com

Did you turn on the command-line tools through Xcode?

If so, what happens when you run:

> which g++

This should be from a new terminal window, of course, after
the install of the command-line tools, so it'll pick up
new paths.

- 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.

Dale

unread,
Oct 17, 2013, 5:33:06 PM10/17/13
to stan-...@googlegroups.com
Not clear to me how to turn on the command-line tools through Xcode. Sounds like I must do something in addition to installing the command-line tools?

elGrande:~ dsteele$ which g++
/usr/bin/g++

elGrande:~ dsteele$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

Thanks.  --Dale

Jiqiang Guo

unread,
Oct 17, 2013, 6:05:48 PM10/17/13
to stan-...@googlegroups.com
The reason might be that in the c++ compiler defined in your R's default Makeconf file (its path can be found by executing R.home("etc")), it reads as follows:



CXX = llvm-g++-4.2 -arch x86_64

But in Xcode 5, this llvm-g++-4.2 does not exist any more.  You need to change it to just g++ or you can create a Makeconf file in your home directory and define CXX there.

Again, to find the file:

> R.home("etc")
[1] "/Library/Frameworks/R.framework/Resources/etc"

--
Jiqiang 

Dale

unread,
Oct 17, 2013, 7:42:52 PM10/17/13
to stan-...@googlegroups.com
Thanks. 

I've edited the Makeconf in:
 /Library/Frameworks/R.framework/Resources/etc

and pasted below.  Unfortunately, same error. --Dale

# etc/Makeconf.  Generated from Makeconf.in by configure.
#
# ${R_HOME}/etc/Makeconf
#
# R was configured using the following call
# (not including env. vars and site configuration)
# configure  'CC=llvm-gcc-4.2 -arch x86_64 -std=gnu99' 'CXX=llvm-g++' 'OBJC=llvm-gcc-4.2 -arch x86_64' 'F77=gfortran-4.2 -arch x86_64' 'FC=gfortran-4.2 -arch x86_64' 'CFLAGS=-mtune=core2 -g -O2' 'CXXFLAGS=-mtune=core2 -g -O2' 'OBJCFLAGS=-mtune=core2 -g -O2' 'FCFLAGS=-g -O2' 'F77FLAGS=-g -O2' '--with-system-zlib' '--enable-memory-profiling' '--disable-openmp' '--with-tcltk=/usr/local/lib'

## This fails if it contains spaces, or if it is quoted
include $(R_SHARE_DIR)/make/vars.mk

AR = ar
## Used by packages 'maps' and 'mapdata'
AWK = awk
BLAS_LIBS = -L$(R_HOME)/lib$(R_ARCH) -lRblas
C_VISIBILITY = 
CC = llvm-gcc-4.2 -arch x86_64 -std=gnu99
CFLAGS = -mtune=core2 -g -O2 $(LTO)
CPICFLAGS = -fPIC

Jiqiang Guo

unread,
Oct 18, 2013, 9:35:59 PM10/18/13
to stan-...@googlegroups.com
I did not see the definition of CXX from what you posted.  Anyway, again the CXX defined in that file should exist in your system and be a c++ compiler. 

--
Jiqiang 

Dale

unread,
Oct 20, 2013, 5:14:03 PM10/20/13
to stan-...@googlegroups.com
Sorry to be dense - I've tried 'CXX=llvm-g++' and 'CXX=g++'.  Neither seems to work. In a default install of Xcode 5 - how should 'CXX=....' be defined?  Thanks.  --Dale


On Thursday, October 17, 2013 6:05:48 PM UTC-4, Jiqiang Guo wrote:

Bob Carpenter

unread,
Oct 20, 2013, 5:18:15 PM10/20/13
to stan-...@googlegroups.com
It should just be "g++".

Have you installed the command-line tools along with Xcode? That
should set up the "g++" command for you. At that point, you should
be able to type:

$ g++ --version

into a terminal window and see that it's the latest version. For
me, that looks like:

$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

- Bob
Reply all
Reply to author
Forward
0 new messages