Tuesday, September 13, 2011

/usr/bin/ld cannot find -lliblapack.so

We were linking our c program to gcc which require the lapack and blas libraries. I did not compile my own libraries but uses instead the CentOS lapack and blas libraries. For more information on installing lapack and blas Installing lapack, blas and atlas on CentOS 5.4

We will compiling our codes
$ gcc exact.c -L/usr/lib64 -lliblapack.so.3 -llibblas.so.3
The result error
/usr/bin/ld: cannot find -lliblapack.so.3
collect2: ld returned 1 exit status

I checked my /etc/ld.so.conf.d/ to ensure that I have /usr/lib64. Of course remember to do a ldconfig if you have made any changes

If the -L and -I does not allow linking process to scan correctly, do a direct complete pathing of the library like the one below and it compile nicely
$ gcc exact.c /usr/lib64/liblapack.so.3 /usr/lib64/libblas.so.3

In case you do not know where to locate your libraries, you can do a
$ locate liblapack

For similar notes on the linking challenges, you may want to explore this forum thread
problems in linking lapack to g77

No comments: