使用Xcode 5.0和Rcpp时出错(安装了命令行工具) [英] Error when with Xcode 5.0 and Rcpp (Command Line Tools ARE installed)

查看:165
本文介绍了使用Xcode 5.0和Rcpp时出错(安装了命令行工具)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个新的iMac,我正在尝试使用Rcpp库运行代码,该库已在我的旧iMac和Macbook Pro上正常运行.我已经尝试了所有似乎无法弄清楚问题出在哪里的方法.

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已下载.然后安装命令行工具.已安装R3.0.2. 我下载了gcc编译器.在终端中输入gcc时,我会收到"clang:".

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

推荐答案

我不确定我下载了gcc编译器"是什么意思.您无需下载自己的gcc.您可以使用默认值或使用clang ++,方法是在~/.R/Makevars文件中输入以下内容:

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

尝试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

Rcpp::evalCpp:

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

这篇关于使用Xcode 5.0和Rcpp时出错(安装了命令行工具)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆