problems in linking lapack to g77

Open discussion regarding features, bugs, issues, vendors, etc.

problems in linking lapack to g77

Postby gradenig » Tue Oct 11, 2005 3:18 pm

it's nearly a weak i'm trying different commands to link my lapack libraries when i compile my fortran77 codes with g77.
Blas and Lapack libraries hava been installed and compiled automatically on my ubuntu linux release by a programm called 'Synaptic Package Manager'.
Searching on web i foud the command
g77 -o example.o example.f -L/usr/local/lib/ -llapack -lblas
Reading this i argued /usr/local/lib is the directory where lapack and blas shared library or symbolic links to shared libraries have been located; so i changed the path and i filled with /usr/lib/atlas, where i found files like But nothing works!
When i try to compile a message appears saying:
/usr/bin/ld: cannot find -llapack
collect2: ld returned 1 exit status
So...can anyone help me?
Thank you very much, Giacomo
Posts: 2
Joined: Tue Oct 11, 2005 2:35 pm

Postby Julie » Tue Oct 11, 2005 4:04 pm


First, you have to find out where exactly is your lapack library, and what is its name?
Code: Select all
locate liblapack

Usually, it is in /usr/local/lib and its name is liblapack.a or

Atlas is a blas optimised library. It provides the blas library optimised for your machine and a part of the lapack library (this is the one you have found),
But as you have installed Lapack, you should have the complete Lapack library somewhere else on your computer.

once you know the exact path to your Atlas and Lapack libraries :
- compile your program
Code: Select all
g77 -c example.f

- link your program to the lapack library and the atlas library with the correct path
Code: Select all
g77 -o example example.o $PATH_LAPACK/liblapack.a $PATH_ATLAS/libf77blas.a $PATH_ATLAS/libatlas.a

or for dynamic linking
Code: Select all
g77 -o example example.o $PATH_LAPACK/liblapack.so3 $PATH_ATLAS/libf77blas.a $PATH_ATLAS/libatlas.a

In fact the -L in the linking process scan the directory and search for libXXX.a if you put -lXXX. Another way to do it, is to directly put the complete path of the library in the linking command. (What I did).

If you really having trouble, you can download lapack from and install it manually.
You can get documentation here:

Posts: 299
Joined: Wed Feb 23, 2005 12:32 am
Location: ICL, Denver. Colorado

Postby gradenig » Fri Oct 14, 2005 10:36 am

Hi julie,
finally I could overcome the situation!
Your mail has been helpful to me to understand what was the exact object looked for by the command -l !
The path i gave to -L was right but no file was found by -l because all were named like and none only or
In the end i had only to rename the binary files containig the shared libraries taking away the suffix .3 and everything worked!
thank you, giacomo.
Posts: 2
Joined: Tue Oct 11, 2005 2:35 pm

Return to User Discussion

Who is online

Users browsing this forum: Google [Bot] and 2 guests