You need to put the library at the end of the compilation when you link the program:
gcc Dirac.c -o Dirac -llapack -lm
How the linking process works is that the library is used to look for unresolved characters that have appeared so far. When you put -llapack first, since your program does not yet have unresolved characters (since it has not compiled anything yet), this does not lead to the use of a library.
source share