title: Call LAPACK function in Fortran code using f2py
body: <p>I want to inverse matrices using Fortran90 code and LAPACK libraries and make it usable with Python using f2py. Here is my subroutine that I want to implement in Python with f2py:</p>
  <pre><code>subroutine inv(A,Ainv)
      implicit none
  
    real(kind=8), dimension(:,:), intent(in) :: A
    real(kind=8), dimension(size(A,1) ,size(A,2)),intent(out) :: Ainv
  
    real(kind=8), dimension(size(A,1)) :: work  ! work array for LAPACK
    integer, dimension(size(A,1)) :: ipiv   ! pivot indices
    integer :: n, info
  
    ! External procedures defined in LAPACK
    external DGETRF
    external DGETRI
  
    ! Store A in Ainv to prevent it from being overwritten by LAPACK
    Ainv = A
    n = size(A,1)
  
    ! DGETRF computes an LU factorization of a general M-by-N matrix A
    ! using partial pivoting with row interchanges.
    call DGETRF(n, n, Ainv, n, ipiv, info)
  
    if (info /= 0) then
       stop 'Matrix is numerically singular!'
    end if
  
    ! DGETRI computes the inverse of a matrix using the LU factorization
    ! computed by DGETRF.
    call DGETRI(n, Ainv, n, ipiv, work, n, info)
  
    if (info /= 0) then
       stop 'Matrix inversion failed!'
    end if
  end subroutine inv
  </code></pre>
  <p>This code works when i compile and run it in a fortran program.</p>
  <p>Then, to compile it with f2py I use the command:</p>
  <pre><code>f2py -c inverse.f90 -m inverse --fcompiler=gnu95 --compiler=mingw32 -L. -lliblapack
  </code></pre>
  <p>It compiles and the module <code>inverse.cp38-win_amd64.pyd</code> is created and normally I should be able to import it in Python shell but I have the following error:</p>
  <pre><code>&gt;&gt;&gt; import inverse
  Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  ImportError: DLL load failed while importing inverse: the specified module is not found.
  </code></pre>
  <p>I think that the DLL file is the LAPACK library used, so I would like to know if there is a way to link LAPACK library with f2py different from <code>-L/path/to/library and -l&lt;library.dll&gt;</code></p>
  <p>The gfortran compiler that I use is with MinGW 64bit, my python version is 3.8.5 and 64bit, my LAPACK libraries are pre-build libraries in 64bit also and I am on Windows 10.</p>
  <p>Thank you for your help !</p>
  <p>Dorian</p>