c++ - RcppArmadillo 和 R 3.1.3 以及 Mac Yosemite 的编译错误

标签 c++ r xcode osx-yosemite gfortran

我最近安装了 R 3.1.3。我使用的是带有 Yosemite 系统的 Mac,我的 Xcode 是 6.2 版。

在我使用 sourceCpp("try.cpp") 获取 CPP 文件后,出现以下错误。我的 try.cpp 文件有

#include <RcppArmadillo.h>
#include <math.h>

错误在R中

ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_15736.so] Error 1
clang++ -arch x86_64 -ftemplate-depth-256 -I/Library/Frameworks/R.framework/Resources/include     -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include  -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"    -fPIC  -mtune=core2 -O3    -c CAR.cpp -o CAR.o
clang++ -arch x86_64 -ftemplate-depth-256 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module - multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -   L/usr/local/lib -o sourceCpp_15736.so CAR.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp("~/RA2015/Code/BYMCAR/CAR.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).

我已经为 Xcode 安装了命令行工具,我的 gfortran 版本是 4.9.0 但是当我输入

gfortran --version

它有以下错误:

 gfortran: warning: couldn’t understand kern.osversion ‘14.1.0

我之前用R 3.1.2的时候没有遇到过这个问题!

感谢任何帮助!

最佳答案

经过一番查找,我在网上找到了解决方案。

如果你和我有同样的问题,只需输入

curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /

在终端和sourceCpp上都能顺利运行。

详细解释可以在[ http://www.thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error]

关于c++ - RcppArmadillo 和 R 3.1.3 以及 Mac Yosemite 的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29224710/

相关文章:

c++ - boost 错误 : not found boost_date_time-vc80-mt-1_41. dll

c++ - 堆损坏 - 加载文件(StaticMesh)

ios - 在 Swift 中使用 UIGestureRecognizer 处理自定义类

ios - 在ios/xcode中可以打开自动布局但没有限制吗

ios - Swift Array 在 Xcode 6.1.1 中导致索引问题

c++ - 在比较 2 个短裤的过度对齐结构时,gcc 是否错过了优化机会?

R 试图让插入符/rfe 工作

r - 如何根据 MuMIn model.avg() 摘要进行绘图

r - 编译RSweave文件:文件不是ASCII

c++ - 使用 C++ lambda 正确实现 finally block