title: "Undefined reference to SSYEV" error while using LAPACK in a module in fortran
body: <p>I have created the following module: <code>quantum.f90</code></p>
  <pre><code>module quantum
  implicit none
  
  contains
  
  function renyi_entropy(A, N, p) result(entropy)
      implicit none
      integer :: N, p, INFO, i
      real :: A(N,N), eval(N), WORK(3*N-1)
      real :: entropy
  
      call SSYEV('N', 'U', N, A, N, eval, WORK, 3*N-1, INFO)
  
      entropy = 0.0
  
      if (p == 1) then
          do i = 1,N            
              entropy = entropy - eval(i)*LOG(eval(i))
          end do
      else
          do i = 1,N
              entropy = entropy + eval(i)**p
          end do
          entropy = LOG(entropy) / (1-p)
      end if
  
      entropy = entropy / LOG(2.0)
  
  end function renyi_entropy
  
  end module quantum
  </code></pre>
  <p>I use it in my program <code>wishart.f90</code> as follows:</p>
  <pre><code>program wishart
  use quantum
  implicit none
  
  integer :: d1, d2
  real, allocatable :: A(:, :), W(:, :)
  
  d1 = 4
  d2 = 3
  allocate(A(d1, d2), W(d1, d1))
  
  call random_number(A)
  
  W = matmul(A, transpose(A))
  
  print*, renyi_entropy(W, d1, 1)
  
  end program wishart
  </code></pre>
  <p>On the command line I give: <code>gfortran -c quantum.f90 wishart.f90 -llapack -lblas</code> and then <code>gfortran quantum.o wishart.o</code>. This results in</p>
  <pre><code>quantum.o: in function `__quantum_MOD_renyi_entropy':
  quantum.f90:(.text+0x13e): undefined reference to `ssyev_'
  collect2: error: ld returned 1 exit status
  </code></pre>