0
votes

I have a Fortran 90 program which uses lapack subroutines, and is successfully running on my Ubuntu system. Now I want to run it on Mac (OS X Version 10.11.4). I am using gfortran compiler as a part of gcc, installed from homebrew repositories, and lapack library, installed in /usr/local/lib/. When I try to compile my code, I get the following error:

gfortran my_prog.f90 -L/usr/local/lib/ -llapack
Undefined symbols for architecture x86_64:
  "_daxpy_", referenced from:
      _zggbal_ in liblapack.a(zggbal.o)
...     
  "_ztrmv_", referenced from:
      _zlarft_ in liblapack.a(zlarft.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

After some google search I understood that the problem is because the linking. When I compile it like this, everything works well:

gfortran my_prog.f90 -llapack

Also when llapack from framework accelerate is used, the compiler doesn't complain.

gfortran my_prog.f90 -framework accelerate

The libraries are of x86-64 architecture:

lipo -info *.a
input file libfftw3.a is not a fat file
input file liblapack.a is not a fat file
Non-fat file: libfftw3.a is architecture: x86_64
Non-fat file: liblapack.a is architecture: x86_64

LAPACK is not the only one which gives me an error, later the same problem appears with FFTW3. Could you please give me a hint to the solution to this problem?

1
daxpy and ztrmv are parts of the Blas library, not lapack. Hence, could you try to link against Blas by doing -llapack -lblas ?francis

1 Answers

0
votes

FFTW is not part of the accelerate framework. If you want to use it, you need to add -lfftw3 to the compile options as well.

If the libraries are not in the default LIBRARY_PATH, you might need to specify -L/path/to/fftw/libs as well. The same holds for the include path if you are using its modules -I/path/to/fftw/includes.

Note that the vDSP part of the library also provides FFT implementations. You might not need FFTW at all.