BLAS, ATLAS, LAPACK Shared library minimal example

泄露秘密 提交于 2019-12-02 07:36:16

问题


I installed atlas, blas and lapack x86_64 packages via

yum install atlas.x86_64 blas.x86_64 lapack.x86_64

on a Redhat 6.6 (ii) distro which installs a shared library but am having problems compiling and linking. For example, if I try to compile the minimal working example:

program main
  print *, 'hello world'
end program main

using

gfortran -L. main.f90 -llapack -lblas -o main

the compiler doesn't find the libraries and I get the error message:

/usr/bin/ld: cannot find -llapack
collect2: ld returned 1 exit status 

I'm relatively new to fortran and linux so I'm probably missing something obvious. I'm lost hours on compiling the libraries from source unsuccessfully too.

Pointers much appreciated.


回答1:


You need to install the *-devel versions of those packages.

E.g., with a virtual Fedora 17 system I had lying around:

$ cat main.f90
program main
  print *, 'hello world'
end program main
$ gfortran -L. main.f90 -llapack -lblas -o main
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
$ sudo yum install atlas.x86_64 blas.x86_64 lapack.x86_64
...
Installed:
  blas.x86_64 0:3.4.2-2.fc17            lapack.x86_64 0:3.4.2-2.fc17           

Complete!
$ gfortran -L. main.f90 -llapack -lblas -o main
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
$ sudo yum install atlas-devel.x86_64 blas-devel.x86_64 lapack-devel.x86_64
...
Installed:
  atlas-devel.x86_64 0:3.8.4-3.fc17       blas-devel.x86_64 0:3.4.2-2.fc17     
  lapack-devel.x86_64 0:3.4.2-2.fc17     

Complete!
$ gfortran -L. main.f90 -llapack -lblas -o main
(Success)


来源:https://stackoverflow.com/questions/28057585/blas-atlas-lapack-shared-library-minimal-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!