gcc linking

Dima Sorkin dima.sorkin@gmail.com
Thu Jun 26 08:18:00 GMT 2008

 I link LAPACK and BLAS in the following way:
 With static libs, I use "-L" and "-l" options (read the gcc manual on these).
 With dynamic libs, I pass their names as is to the linkage command.

Suppose your (static) libs are
/usr/lib/libatlas.a  <-- optionally, if you have ATLAS installed.

On linking, do:
gcc -o my_exe my_obj1.o my_obj2.o -L/usr/lib -lclapack -lcblas -latlas

Dynamic libs:

On linking, do:
gcc -o my_exe my_obj1.o my_obj2.o /usr/lib/libclapack.so /usr/lib/libcblas.so


On 6/24/08, mcwalker@purdue.edu <mcwalker@purdue.edu> wrote:
> Hello,
> I am trying to link the CLAPACK/CBLAS libraries with a C program using gcc (on a
> RedHat Linux machine).  I know where the library file is located, but don't know
> how to link with it.  I did not install the libraries myself, but I've been
> assured that they are compiled.  Is there something I need to change in the
> environment variables?  I don't know which version of gcc I am using.  If I can
> clarify any information needed for this query, please let me know.
> Thank you,
> Mike Walker

More information about the Gcc-help mailing list