RcppArmadillo:在Mac上安装软件包时出错

时间:2016-04-06 17:47:54

标签: r rcpp

我有一个R软件包,我试图在MAC OS(yosemite)上安装,我收到链接器问题。这是我得到的错误

clang++ -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 File1.so File2.o File3.o File4.o RcppExports.o Utils.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

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 -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mypackage.so] Error 1
ERROR: compilation failed for package ‘mypackage’

我的Makevars文件包含:

PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

DESCRIPTION中,我有:

Depends:
    R (>= 3.2.0),
    Rcpp,
    RcppArmadillo
LinkingTo: Rcpp, RcppArmadillo

R/help.R,我有:

#' @importFrom Rcpp evalCpp
#' @import RcppArmadillo
#' @useDynLib mypackage
NULL

这与此question不同,因为我已将Armadillo依赖项包含在其他.cpp文件所隐藏的头文件中:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <Rmath.h>
#include <RcppArmadillo.h>

// [[Rcpp::depends(RcppArmadillo)]]

我错过了什么吗?是否应该修改makefile?

1 个答案:

答案 0 :(得分:7)

修正:

轻松修复

Terminal

打开/Applications/Utilities/

Terminal

中输入以下内容
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 /

耗时更多:

使用homebrewmacports抓取包含gcc的{​​{1}}。更改gfortran。 (有关使用~/.R/Makevars的gfortran安装的更多详细信息,请参阅openmp帖子。)

请参阅:

  1. http://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-os-x/
  2. http://thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error/
  3. http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/
  4. https://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-FAQ.pdf#page=8