4

I am working on understanding a fellow physicist's code in C that uses Lapack, which I have never used before. I used sudo apt-get to install lapack. and I've been compiling with

gcc  -llapack Dirac.c -o Dirac -lm

and I'm getting the compiling error "undefined reference to 'zheev'" I know zheev is a function in lapack, so I'm figuring something went wrong with the install or something is not in the right place. Can someone please explain if i need to do some kind of linking or where i need to save things to get this to compile? I apologize if this is a noob question.

Gerhard
  • 1,925
  • 3
  • 15
  • 24
Beth
  • 181
  • 9

1 Answers1

4

You need to put the library at the end of compilation when you are linking the program:

gcc Dirac.c -o Dirac -llapack -lm

The way the linking process works is that the library is used to find unresolved symbols that have come up so far. When you put -llapack first, since there are not yet any unresolved symbols in your program (since it hadn't compiled anything yet), it doesn't end up using the library.

jxh
  • 69,070
  • 8
  • 110
  • 193