title: How to install RcppArmadillo on Apple Silicon (M1) Macs
body: <p>I've been trying many different ways to install RcppArmadillo, but I don't get it to work</p>
  <pre><code>install.packages(c('Rcpp'))
  Sys.setenv(&quot;PKG_CXXFLAGS&quot;=&quot;-std=c++11&quot;)
  install.packages(c('RcppArmadillo'),type = &quot;source&quot;)
  </code></pre>
  <p>It gives me this error:</p>
  <pre><code>ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
  ld: library not found for -lquadmath
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [RcppArmadillo.so] Error 1
  ERROR: compilation failed for package ‘RcppArmadillo’
  * removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo’
  </code></pre>
  <p>Obviously, I don't have <code>x86_64-apple-darwin18/8.2.0</code> since I installed gfortran <a href="https://github.com/fxcoudert/gfortran-for-macOS/releases" rel="nofollow noreferrer">for the apple silicon architecture</a>.</p>
  <p>Mac version:</p>
  <pre><code>macOS Big Sur 
  11.2.3
  Apple M1
  </code></pre>
  <p>R version:</p>
  <pre><code>version
                 _                           
  platform       x86_64-apple-darwin17.0     
  arch           x86_64                      
  os             darwin17.0                  
  system         x86_64, darwin17.0          
  status                                     
  major          4                           
  minor          0.4                         
  year           2021                        
  month          02                          
  day            15                          
  svn rev        80002                       
  language       R                           
  version.string R version 4.0.4 (2021-02-15)
  nickname       Lost Library Book           
  </code></pre>