有没有办法获得liblapack.a的版本?

时间:2015-02-13 11:08:35

标签: lapack

我通过使用cmake编译来安装lapack 3.4.2和3.5.0。在我的lapack 3.5.0的安装目录中,我找到一个文件./pkgconfig/lapack.pc,说Version: 3.4.2。所以我不确定我是否真的在那里安装了lapack 3.5.0。

有没有办法直接从lib liblapack.a(或Windows下的LAPACK.lib)获取lapack版本?例如,从库中的例程或使用特定工具?

2 个答案:

答案 0 :(得分:2)

lapack函数ilaver()是为你制作的!

它的原型是自我解释的:

subroutine ilaver   (   integer     VERS_MAJOR,
    integer     VERS_MINOR,
    integer     VERS_PATCH 
)   

以下是两个演示如何使用它的程序:

  • 在fortran程序中,遵守gcc main.f90 -o main -llapack

    PROGRAM VER
    IMPLICIT NONE
    
      INTEGER major, minor, patch
      CALL ilaver( major,minor, patch )
      WRITE(*,*) "LAPACK ",major,".",minor,".",patch
    END PROGRAM VER
    
  • 在由gcc main.c -o main -llapack

    编译的c程序中
    #include <stdio.h>
    
    extern ilaver_(int* major,int* minor,int* patch);
    
    int main()
    {
    
        int major=0;
        int minor=0;
        int patch=0;
    
        ilaver_(&major,&minor,&patch);
    
        printf("lapack %d.%d.%d\n",major,minor,patch);
    }
    

答案 1 :(得分:1)

如果您不想编译任何内容,可以在Python中执行此操作:

ATL-MBP-MAC4:~ dmcdonald$ python3
Python 3.4.2 (default, Jan 29 2015, 06:34:22) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> from ctypes.util import *
>>> lapack = CDLL(find_library("lapack"))
>>> major, minor, patch = c_int(), c_int(), c_int()
>>> lapack.ilaver(byref(major), byref(minor), byref(patch))
0
>>> print("{0}.{1}.{2}".format(major.value, minor.value, patch.value))
3.2.1