Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

r - Error when with Xcode 5.0 and Rcpp (Command Line Tools ARE installed)

I have a new iMac and I'm trying to run code using the Rcpp library that has been working on both my old iMac and Macbook Pro without issue. I have tried everything I can't seem to figure out what the issue is.

Xcode 5.0 downloaded. Command line Tools then installed. R3.0.2 is installed. I downloaded a gcc compiler. When I type gcc in terminal - I get "clang:" - which is good, I think.

The error I get is copied below. Thanks in advance for any ideas and advice.

Error (in R console):
llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include  -I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include"    -fPIC  -mtune=core2 -g -O2  -c SBM-Ccode.cpp -o SBM-Ccode.o 
Error in sourceCpp("SBM-Ccode.cpp") : 
  Error 1 occurred building shared library.

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

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

/bin/sh: llvm-g++-4.2: command not found
make: *** [SBM-Ccode.o] Error 127
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm not sure what you mean by "I downloaded a gcc compiler". You don't need to download your own gcc. You can use either the default or use clang++ by having something like this in your ~/.R/Makevars file:

CC=clang
CXX=clang++
CXXFLAGS= -O3 -pedantic

What happens when you try devtools::has_devel:

> require(devtools)
> has_devel()
'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD SHLIB foo.c

clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c foo.c -o foo.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
[1] TRUE

or Rcpp::evalCpp:

> require(Rcpp)
> evalCpp( "1+1")
[1] 2    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...