I am using fpm and locally installed Lapack and Blas libraries to test the Ax=b for a simple case (without fpm the example works perfectly): here is the example
program main
use example1, only: say_hello ! calling module example1.f90 from src
implicit none
external :: sgesv
real :: amat(2, 2)
real :: bvec(2)
real :: pivot(2)
integer :: rcval ,i, j
amat = reshape([ 2., 3., 2., 2. ], [ 2, 2 ])
bvec = [ 3., 6. ]
print*, 'Amat: '
do j = 1,2
print*, (amat(i,j),i=1,2)
enddo
call sgesv(2, 1, amat, 2, pivot, bvec, 2, rcval)
if (rcval /= 0) then
print '(a, i0)', 'Error: ', rcval
stop
end if
print*, "bvec: ", bvec
print '("solution: x vect ", f0.6, ", ", f0.6)', bvec
call say_hello()
!
! using gFortran for this test_example.f90 work fine
! gfortran -L/usr/loca/lib -o example.x example.f90 -llapack -lblas && ./example.x
!! Amat:
! 2.00000000 3.00000000
! 2.00000000 2.00000000
! bvec: 3.00000000 -1.50000012
! solution: x vect 3.000000, -1.500000
!
end program main
With fpm, I am getting the following error:
fpm build --flag "-L/usr/loca/lib -lblas -llapack"
example1 failed.
[100%] Compiling...
/usr/bin/ld: build/gfortran_76E40220992853F5/example1/app_main.f90.o: in function `MAIN__':
main.f90:(.text+0x199): undefined reference to `sgesv_'
collect2: error: ld returned 1 exit status
<ERROR> Compilation failed for object " example1 "
<ERROR>stopping due to failed compilation
STOP 1
Any suggestion will be very helpful.