title: Compile Fortran source with Accelerate Framework (LAPACK and BLAS)
body: <p>I wish to compile <code>Fortran</code> source code which uses functions from <code>LAPACK</code> and <code>BLAS</code>. When I compile a single source code file e.g. </p>
  
  <pre><code>gfortran -g -framework accelerate test.f
  </code></pre>
  
  <p><em>it works</em>.</p>
  
  <p>However, I have many source code files which I want to compile through <code>Makefile</code>. When I modify my <code>Makefile</code> by adding:</p>
  
  <pre><code>LDFLAGS= -framework Accelerate 
  </code></pre>
  
  <blockquote>
    <p>(Not sure it is the right way but that's how someone seemed to do it)
    I get the error that the lapack function used inside is unrecognized. </p>
  </blockquote>
  
  <p>Can someone tell me what modification to do in the makefile?</p>
  
  <p>Here is the error I get:</p>
  
  <pre><code>gfortran -g test.o  -o a.out
  Undefined symbols for architecture x86_64:
    "_sgesv_", referenced from:
       _MAIN__ in test.o
  ld: symbol(s) not found for architecture x86_64
  collect2: error: ld returned 1 exit status
  make: *** [a.out] Error 1
  </code></pre>
  
  <p>sgesv is the lapack subroutine being called which shall be included in veclib/accelerate framework.</p>
  
  <p>Here is the copy of my Makefile:</p>
  
  <pre><code>#
  #              
  #
  #FFLAGS = -fast
  #FFLAGS = gfortran
  FC = gfortran
  LFLAGS = gfortran -g
  LINK = gfortran -g
  LDFLAGS = -framework Accelerate
  OBJECTS = test.o\
  
  SOURCES = test.f\
  
  a.out:  $(OBJECTS)
      $(LINK) $(OBJECTS) -o a.out
  </code></pre>
  
  <p>For others:</p>
  
  <p>Here was what I was doing wrong. The last line should change:
         $(LINK) $(OBJECTS) -o a.out $(LDFLAGS)</p>