I am trying to build a .so that dynamically links against lapack and blas at runtime. When building, the linker complains that it cannot find lapack and blas, but I am pointing right to them (I think). What else might I be missing?
I am on a Rocky 9 Linux system (pretty fresh install). Among other things, I have done yum install gcc-gfortran lapack-3.9.0-8.el9.x86_64 compat-libgfortran-48-4.8.5-36.5.el9.x86_64 openblas-serial lapack scalapack-common
and also yum groupinstall "Development tools"
. Some of these were done to (successfully) get old binaries working again, but I include them in case they might be interfering now. With yum list
, I don't see anything else promising to install.
In /usr/lib64/
I see (among other things):
lrwxrwxrwx. 1 root root 18 May 25 2022 liblapack.so.3.9 -> liblapack.so.3.9.0*
lrwxrwxrwx. 1 root root 19 May 25 2022 liblapacke.so.3.9 -> liblapacke.so.3.9.0*
lrwxrwxrwx. 1 root root 19 May 25 2022 liblapacke.so.3 -> liblapacke.so.3.9.0*
-rwxr-xr-x. 1 root root 7496688 May 25 2022 liblapack.so.3.9.0*
-rwxr-xr-x. 1 root root 2908088 May 25 2022 liblapacke.so.3.9.0*
lrwxrwxrwx. 1 root root 18 Jan 18 16:18 liblapack.so.3 -> liblapack.so.3.9.0*
lrwxrwxrwx. 1 root root 22 May 16 2022 libopenblas.so.0 -> libopenblas-r0.3.15.so*
lrwxrwxrwx. 1 root root 23 May 16 2022 libopenblaso.so.0 -> libopenblaso-r0.3.15.so*
-rwxr-xr-x. 1 root root 38111888 May 16 2022 libopenblas-r0.3.15.so*
-rwxr-xr-x. 1 root root 39653512 May 16 2022 libopenblaso-r0.3.15.so*
lrwxrwxrwx. 1 root root 17 May 25 2022 libcblas.so.3.9 -> libcblas.so.3.9.0*
lrwxrwxrwx. 1 root root 16 May 25 2022 libblas.so.3.9 -> libblas.so.3.9.0*
-rwxr-xr-x. 1 root root 119640 May 25 2022 libcblas.so.3.9.0*
-rwxr-xr-x. 1 root root 583120 May 25 2022 libblas.so.3.9.0*
lrwxrwxrwx. 1 root root 19 Jun 2 2022 libflexiblas.so.3 -> libflexiblas.so.3.0*
lrwxrwxrwx. 1 root root 24 Jun 2 2022 libflexiblas_mgmt.so.3 -> libflexiblas_mgmt.so.3.0*
lrwxrwxrwx. 1 root root 23 Jun 2 2022 libflexiblas_api.so.3 -> libflexiblas_api.so.3.0*
-rwxr-xr-x. 1 root root 3870704 Jun 2 2022 libflexiblas.so.3.0*
-rwxr-xr-x. 1 root root 53256 Jun 2 2022 libflexiblas_mgmt.so.3.0*
-rwxr-xr-x. 1 root root 15912 Jun 2 2022 libflexiblas_api.so.3.0*
lrwxrwxrwx. 1 root root 17 Jan 18 16:18 libcblas.so.3 -> libcblas.so.3.9.0*
lrwxrwxrwx. 1 root root 16 Jan 18 16:18 libblas.so.3 -> libblas.so.3.9.0*
In addition, whereis liblapack.so
and whereis libblas.so
both come up empty-handed.
Following what I see here, I have done:
gcc -Wall -fPIC -O -g -fopenmp mylib.c -c -o mylib.pic.o
gcc -shared -fopenmp mylib.pic.o -L/usr/lib64 -lblas -llapack -lm -o mylib.so
but I get
/usr/bin/ld: cannot find -lblas
/usr/bin/ld: cannot find -llapack
collect2: error: ld returned 1 exit status
I know about this, but it seems wrong that I would have to get into system directories and manually make soft links in order to use standard infrastructure. There must be a "right" solution I am missing.
Thanks for any help.
I am pointing right to them (I think).
No, you are not. You need libblas.so
, which is not the same as libblas.so.3
.
The libblas.so
is needed to link new binaries against libblas
. The libblas.so.3
is needed to run already linked binaries.
Usually the .so
libraries are installed as part of libblas-devel
or a similar package.