【问题标题】:Compile error with RcppArmadillo and R 3.1.3 and Mac Yosemite使用 RcppArmadillo 和 R 3.1.3 和 Mac Yosemite 编译错误
【发布时间】:2015-05-27 07:07:09
【问题描述】:

我最近安装了 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的时候,之前没有遇到过这个问题!

感谢任何帮助!

【问题讨论】:

    标签: c++ r xcode osx-yosemite gfortran


    【解决方案1】:

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

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

    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]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-18
      • 2017-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多