title: RcppArmadillo Compile Errors on OS X Mavericks
body: <p>This is a follow-up to the question at <a href="https://stackoverflow.com/questions/19917023/element-wise-matrix-multiplication-in-rcpp">Element-Wise Matrix Multiplication in Rcpp</a></p>
  
  <p>I have been getting a number of different kinds of errors with RcppArmadillo since upgrading to Mavericks. I have Xcode 5.0.2 and Command Line Tools installed. Also, gfortran from Homebrew. But I keep encountering the error below --</p>
  
  <pre><code>&gt; cppFunction("arma::mat schur(arma::mat&amp; a, arma::mat&amp; b) 
                         { return(a % b); }", depends="RcppArmadillo")
  
  
  ld: library not found for -lgfortran
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [sourceCpp_18474.so] Error 1
  clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include  -    I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RcppArmadillo/include"    -fPIC  "-mtune=native -g -O2 -Wall -pedantic -Wconversion" -c fileaf992bfb8f84.cpp -o fileaf992bfb8f84.o clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o sourceCpp_18474.so fileaf992bfb8f84.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -lgfortran /Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/lib/libRcpp.a -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation 
  Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput,  : 
  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).
  
  # Contents of Makevars
  $ cat ~/.R/Makevars 
  CC=clang
  CXX=clang++ 
  CXXFLAGS="-mtune=native -g -O2 -Wall -pedantic -Wconversion"
  FLIBS=-lgfortran
  </code></pre>
  
  <p>Commenting <code>FLIBS=-lgfortran</code> does not help and results in even more error messages --</p>
  
  <pre><code>&gt; cppFunction("arma::mat schur(arma::mat&amp; a, arma::mat&amp; b) { return(a % b); }", depends="RcppArmadillo")
  ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64'
  ld: warning: directory not found for option '-L/usr/local/lib/x86_64'
  ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3'
  ld: library not found for -lgfortran
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [sourceCpp_50381.so] Error 1
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Following suggestions from response from Kevin and Dirk below, I re-installed Rcpp, RcppArmadillo and inline from source and updated FLIBS to point to the actual directory. This solved the issue.</p>
  
  <pre><code># Update FLIBS in ~/.R/Makevars
  FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran
  #Re-Install from source
  install.packages(c("Rcpp","RcppArmadillo","inline"),type="source")
  #Restart R
  </code></pre>