Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7068 Discussions

Trouble linking to BLAS library with fortran compiler

Clint_S_
Beginner
269 Views

So I am trying to get accustomed to linking my f90 code to the MKL library and I decided to start with the $dot function.  I have included my compile command and my code below; please note that I set and environment variable for MKLROOT to save space and time.

My problem is that when I try to compile this, I keep getting the following error: /tmp/ifortdoYMJ3.o: In function `MAIN__':
DotProd.f90:(.text+0x4b7): undefined reference to `sdot_f95_'

I have been trying to figure out where this problem is coming from, without any luck. I was wondering if someone could provide some insight into this problem? I am working on ubuntu, on a 64 bit system.

Any help is appreciated!

----------------------------------Compile Command

ifort DotProd.f90 -L$MKLROOT/lib/intel64/libmkl_blas95_ilp64.a -i8 -I$MKLROOT/include/intel64/ilp64 -I$MKLROOT/include -Wl,--start-group $MKLROOT/lib/intel64/libmkl_intel_ilp64.a $MKLROOT/lib/intel64/libmkl_core.a $MKLROOT/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm -ldl

 

--------------------------------- Code

program DotProd

use f95_precision
use blas95

implicit none
! This program was constructed to learn how to use the BLAS library of the MKL
! The BLAS routine used will be the ?dot routine.

real, dimension(:), allocatable :: a,b ! Define two vectors
real res
integer :: size_of_vectors, ent

! Prompt the user for input
print *, 'Please input the size of the vectors in question'
read *, size_of_vectors

! Define size of vectors
allocate (a(1:size_of_vectors))
allocate (b(1:size_of_vectors))

! Prompt user for vector entries
print *, 'Please input the entries for vector a'
    do ent = 1, size_of_vectors
        read *, a(ent)
    end do

print *, 'Please input the entries for vector b'
    do ent = 1, size_of_vectors
        read *, b(ent)
    end do

! Output vectors
print *, 'Vector a ='
    do ent = 1, size_of_vectors
        print *, a(ent)
    end do
print *, 'Vector b ='
    do ent = 1, size_of_vectors
        print *, b(ent)
    end do
    
res = dot(a,b)
print* , 'a dot b =', res

end program DotProd

0 Kudos
0 Replies
Reply