BLAS,ATLAS,LAPACK共享库最小的例子

时间:2015-01-21 00:19:51

标签: fortran redhat lapack blas atlas

我通过

安装了atlas,blas和lapack x86_64软件包
yum install atlas.x86_64 blas.x86_64 lapack.x86_64

在Redhat 6.6(ii)发行版上安装共享库但是在编译和链接时遇到问题。例如,如果我尝试编译最小的工作示例:

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

使用

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

编译器找不到库,我收到错误消息:

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

我对fortran和linux比较陌生,所以我可能会遗漏一些明显的东西。我也没有成功地从源代码编译库。

指针非常感谢。

1 个答案:

答案 0 :(得分:3)

您需要安装这些软件包的*-devel版本。

,例如,我有一个虚拟的Fedora 17系统:

$ 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)