Reputation: 1747
I have an R package which I am trying to install on a MAC OS (yosemite), and I am getting a linker problem. This is the error that I am getting
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’
My Makevars
file contain:
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
In DESCRIPTION
, I have:
Depends:
R (>= 3.2.0),
Rcpp,
RcppArmadillo
LinkingTo: Rcpp, RcppArmadillo
and in R/help.R
, I have:
#' @importFrom Rcpp evalCpp
#' @import RcppArmadillo
#' @useDynLib mypackage
NULL
This is not the same issue as this question because I already included the Armadillo dependencies in the header file that is being indluced by the other .cpp
files:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <Rmath.h>
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
Am I missing something? Should the makefile be modified?
Upvotes: 3
Views: 3669
Reputation: 20746
Fixes:
Easy fix
Open the Terminal
from /Applications/Utilities/
Type the following into 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 /
More time consuming:
Use homebrew
or macports
to grab gcc
which contains gfortran
. Change the ~/.R/Makevars
. (See the openmp post for more details on the gfortran install with homebrew
.)
See:
Upvotes: 8