英文:
linker not finding shared lapack and blas, but I am pointing right to it
问题
我正在尝试构建一个动态链接到lapack和blas的.so文件,以便在运行时动态链接它们。在构建时,链接器抱怨找不到lapack和blas,但我认为我已经指向了它们。还有什么其他可能被忽略的地方吗?
我正在使用Rocky 9 Linux系统(相当新的安装)。除了其他事情外,我已经执行了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
和yum groupinstall "Development tools"
。其中一些是为了使旧二进制文件重新运行(成功),但我也包括它们以防它们现在会产生干扰。使用yum list
,我看不到其他有望安装的东西。
在/usr/lib64/
目录中,我看到(以及其他内容):
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*
此外,whereis liblapack.so
和whereis libblas.so
都没有找到任何内容。
根据我在这里看到的内容,我已经执行了以下操作:
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
但我得到以下错误信息:
/usr/bin/ld: cannot find -lblas
/usr/bin/ld: cannot find -llapack
collect2: error: ld returned 1 exit status
我知道这个,但似乎不应该需要进入系统目录并手动创建软链接来使用标准基础设施。一定有一个“正确”的解决方案我忽略了。
感谢任何帮助。
英文:
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.
答案1
得分: 1
感谢@EmployedRussian的答案,指引我找到了正确的方向。对于其他初级系统管理员可能会遇到类似问题的人,剩下的故事是,Fedora系统上的yum
似乎正在被dnf
取代。这里的说明很不错(Rocky 9也适用),而这个可搜索的网站对于了解可用的内容非常有用。
长话短说,这解决了我的问题:
dnf --enablerepo=crb install blas-devel lapack-devel
英文:
Thanks to the answer from @EmployedRussian that pointed me in the right direction. For any other sophomore sys-admins stumbling on this, the rest of the story is that it seems that yum
on Fedora systems is being overtaken by dnf
. The instructions here are good (also for Rocky 9), and this searchable site is very useful for knowing what is available.
Long story short, this fixed my problem:
dnf --enablerepo=crb install blas-devel lapack-devel
答案2
得分: 0
我指向它们(我想)。
不,你没有。你需要libblas.so
,这不同于libblas.so.3
。
libblas.so
用于将新的二进制文件链接到libblas
。libblas.so.3
用于运行已链接的二进制文件。
通常,.so
库是作为 libblas-devel
或类似包的一部分安装的。
英文:
> 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论