You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Installing Rcpp Packages on M2 Mac: Fixing gfortran Dependencies
Problem Description
When trying to install R packages that use Rcpp and RcppArmadillo on an M2 Mac, you might encounter linking errors related to gfortran. This typically occurs when building packages that require LAPACK/BLAS linear algebra operations. The error message might look something like this:
ld: warning: search path '/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0' not found
ld: warning: search path '/opt/gfortran/lib' not found
ld: library 'gfortran' not found
clang++: error: linker command failed with exit code 1
Solution Using Homebrew
1. Install gcc/gfortran
First, install gcc (which includes gfortran) using Homebrew:
brew install gcc
2. Verify Installation
You can verify that gfortran was installed correctly by checking its location and version:
# Check location
which gfortran
# Should show: /opt/homebrew/bin/gfortran# Check version
gfortran --version
3. Configure R to Use Homebrew's gfortran
Create or modify your R Makevars file:
# Create ~/.R directory if it doesn't exist
mkdir -p ~/.R
# Create or modify Makevars
touch ~/.R/Makevars
Installing Rcpp Packages on M2 Mac: Fixing gfortran Dependencies
Problem Description
When trying to install R packages that use Rcpp and RcppArmadillo on an M2 Mac, you might encounter linking errors related to gfortran. This typically occurs when building packages that require LAPACK/BLAS linear algebra operations. The error message might look something like this:
Solution Using Homebrew
1. Install gcc/gfortran
First, install gcc (which includes gfortran) using Homebrew:
2. Verify Installation
You can verify that gfortran was installed correctly by checking its location and version:
3. Configure R to Use Homebrew's gfortran
Create or modify your R Makevars file:
Add the following lines to
~/.R/Makevars
:4. Rebuild Your Package
After setting up gfortran, rebuild your R package
The text was updated successfully, but these errors were encountered: