Link Problem with Fortran 90

Post here if you have a question about linking your program with LAPACK or ScaLAPACK library

Link Problem with Fortran 90

Postby carolasu » Wed Mar 21, 2012 1:02 am

I've already compiled lapack-3.4.0. And I am trying to link it to my codes in fortran 90, so I wrote these in Makefile:

FC=gfortran
FFLAGS=-O2
LIBDIR=/home/myname/lapack
LIBS=-llapack -lbrefblas -ltmglib

$(FC) $(LDFLAGS) -o $@ $^ $(LIBS)

But it tells my that: /usr/bin/ld: cannot find -llapack

What else should I do?

Thank you!!!
carolasu
 
Posts: 9
Joined: Wed Mar 21, 2012 12:50 am

Re: Link Problem with Fortran 90

Postby admin » Wed Mar 21, 2012 1:14 am

LIBS=-L$(LIBDIR) -llapack -lrefblas
should work
Julie
admin
Site Admin
 
Posts: 502
Joined: Wed Dec 08, 2004 7:07 pm

Re: Link Problem with Fortran 90

Postby carolasu » Wed Mar 21, 2012 1:33 am

Thank you Julie!!!!!!!! Yes, it works!!!!!!!!!!

But now I have a new problem: when I am running the Makefile, it tells me:

lanczos.o: In function `__lanczos_MOD_dolan':
lanczos.f90:(.text+0x7d9): undefined reference to `dstev_'

I called 'dstev' in my subroutine 'lanczos.f90'. 'dstev' is from lapack, how come it's undefined reference?

Thanks you again!!
carolasu
 
Posts: 9
Joined: Wed Mar 21, 2012 12:50 am

Re: Link Problem with Fortran 90

Postby admin » Wed Mar 21, 2012 2:14 am

indeed, it shouldn't be undefined.
either LAPACK is not built properly, either there is a problem in the call, either there is a mistake at linking time (that is unlikely as you just fixed it).

If you send me your lanczos.f90 and your Makefile, I can take a quick look.

At the same time, check that
Code: Select all
nm /home/myname/lapack/liblapack.a | grep -i dstev
gives you a line like this:
liblapack.a(dstev.o):
0000000000000000 T _dstev_
admin
Site Admin
 
Posts: 502
Joined: Wed Dec 08, 2004 7:07 pm

Re: Link Problem with Fortran 90

Postby carolasu » Wed Mar 21, 2012 5:52 pm

Thank you! Problem solved.

When I added "-L$(LIBDIR) -llapack", I didn't leave space between -L$(LIBDIR) and -llapack.

I fixed that. So there is no problem now.

Thanks for your help!!!
carolasu
 
Posts: 9
Joined: Wed Mar 21, 2012 12:50 am

Re: Link Problem with Fortran 90

Postby markuspiro » Tue Mar 05, 2013 10:07 am

Hello,

I have also experienced a similar issue where the lapack and blas libraries are not found. Instead of manually specifying the path of the libraries in the makefile, how can I make these libraries shared on my machine? I have other computers that already have lapack and blas set up as shared libraries and they can be conveniently used in a makefile.

Thanks,
Markus

Ubuntu 12.04
gfortran 4.6
lapack 3.4.2
markuspiro
 
Posts: 2
Joined: Mon Mar 04, 2013 1:14 pm

Re: Link Problem with Fortran 90

Postby admin » Tue Mar 05, 2013 11:50 am

Markus, you do not have to have them shared, static is fine.

LIBDIR =/Path/to/my/lib
LIBS =-L$(LIBDIR) -llapack -lrefblas

Otherwise if you want to build shared libraries use cmake, and check the shared option.

Hope it helps
admin
Site Admin
 
Posts: 502
Joined: Wed Dec 08, 2004 7:07 pm


Return to Linking Problem

Who is online

Users browsing this forum: No registered users and 1 guest