Question

I am working on a project written in a mix of Fortran 90 and Fortran 77 and now need to link the LAPACK/BLAS libraries, from netlib.org, to the project, all in a Linux environment. I used the gfortran compiler flags OPTS = -O2 -fPIC -m64 in the given Makefile, and then made it using

make blaslib
make

And it finished normally, or at least I think so.

Then, I copied the files in /usr/local/lib and /usr/local/bin/ and /usr/local/lib64/ but it didn't work. I even used the option -L/path/to/lapack/liblapack.a and it didn't work also.

When I compile my code, I get the following error:

qrB.o: In function `qrfactorizeb_':
qrB.f90:(.text+0x64f): undefined reference to `zgeqp3_'
collect2: ld returned 1 exit status
make: *** [run] Error 1

I am really unsure what to make of this error. I tested it in 3 other workstations and it didn't help! Can anyone help me?

Was it helpful?

Solution

I had the same problem some time ago! Dual working with Windows and Linux and also ease of playing with options in Windows taught me something interesting!

Try compiling such as: [...]$ ifort liblapack.a libblas.a libslatec.a *.o -o profmm

and as you know, it means that I want to use 3 libraries to compile and link my files into profmm output file. It has no syntax error, but it leads to a lot of errors like: preconditioner3.o: In function factorb_': preconditioner3.f:(.text+0x1add): undefined reference tozgetrf_' . . preconditioner.o: In function factorpre_': preconditioner.f:(.text+0x13a2): undefined reference tozgetrf_' preconditioner.f:(.text+0x18bb): undefined reference to zgetri_' zbesh.o: In functionzbesh_': zbesh.f:(.text+0xb3): undefined reference to d1mach_' zbesh.f:(.text+0xcf): undefined reference toi1mach_' . . . and many more errors indicating that ifort is unable to read my libraries even though they are here in my current directory!

But simply change the command as follow: [...]$ ifort *.o liblapack.a libblas.a libslatec.a -o profmm

and it works fine with no error! So it means that now ifort can read my library (local ones)! Also note that changing the order of libraries are very important, and it depends on the order of usage of those subroutines inside the program. So always try to reorder the library chain to check for possible errors.

Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top