我有一个问题,无法将LAPACK链接到Fortran示例程序。以下是示例程序example.f95:
Program LinearEquations
! solving the matrix equation A*x=b using LAPACK
Implicit none
! declarations
double precision :: A(3,3), b(3)
integer :: i, pivot(3), ok
! matrix A
A(1,:)=(/3, 1, 3/)
A(2,:)=(/1, 5, 9/)
A(3,:)=(/2, 6, 5/)
! vector b
b(:)=(/-1, 3, -3/)
!b(:)=(/2, 2, 9/)
! find the solution using the LAPACK routine DGESV
call DGESV(3, 1, A, 3, pivot, b, 3, ok)
! print the solution x
do i=1, 3
write(*,9) i, b(i)
end do
9 format('x[', i1, ']= ', f5.2)
end program LinearEquations
我已经在这里安装了库:
/opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/lib/intel64_lin/libmkl_lapack95_ilp64.a
我正在使用gfortran编译程序:
gfortran -o example example.f95 -L/opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/lib/intel64_lin/libmkl_lapack95_ilp64.a
然而它报错了。
/tmp/ccWtxMFP.o: In function `MAIN__':
example.f95:(.text+0xf0): undefined reference to `dgesv_'
collect2: error: ld returned 1 exit status
请问有人能帮我解决这个问题吗?非常感谢