本文介绍了将LAPACK库与cygwin上的g ++链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景



我试图通过使用LAPACK库中的zgeev例程来找到复杂矩阵的特征值。据我所知,LAPACK是为FORTRAN编写的,因此要使用它与C(或C ++)程序,必须进行几个修改,如转换矩阵和附加下划线在例程名称(REFERENCE:)



问题



要将LAPACK库链接到C ++程序()



p>

使用cygwin上的g ++在我的Windows 7笔记本电脑上编译它,我使用以下命令:

  $ g ++ eigen_complex.cpp -LG:\cygwin_root_dir\lib -lliblapack.a -llibblas.a 

并getiing以下结果:

  eigen_complex.cpp:在函数`int main() 
eigen_complex.cpp:41:error:`zgeev_'undeclared(首先使用此函数)
eigen_complex.cpp:41:错误:(每个未声明的标识符仅对其出现的每个函数报告一次。

我不明白是什么原因导致此错误。将库的名称从liblapack更改为lapack或任何东西(比如lapa)对错误没有任何影响。
以下编译命令返回与上述相同的结果

  g ++ eigen_complex.cpp -LG:\cygwin_root_dir\ lib -llapack.a -lblas.a 
g ++ eigen_complex.cpp -LG:\cygwin_root_dir\lib -llapack -lblas
g ++ eigen_complex.cpp -LG:\cygwin_root_dir\lib -lliblapack - llibblas
g ++ eigen_complex.cpp -lliblapack -llibblas

  g ++ eigen_complex.cpp -lliblapack -lxyz 


$ b b


我相信没有名为xyz的库,编译器没有给出任何警告。



任何帮助将非常感激。希望在项目的某个标题中添加这个原型应该可以解决这个问题:



<$> p $ p> externCvoid zgeev_(char *,char *,int *,double *,int *,struct complex [],struct complex [1] complex [1] [1],int *,struct complex [],int *,struct complex [],int *);


Background

I am trying to find the eigenvalues of a complex matrix by using zgeev routine in LAPACK library. As far as I understand, LAPACK is written for FORTRAN and hence to use it with a C (or C++) program one has to make several modifications such as transforming the matrix and appending an underscore in the routine-name (REFERENCE:http://www.physics.orst.edu/~rubin/nacphy/lapack/codes/eigen-c.html)

Problem

To link LAPACK library to a C++ program (http://www.physics.orst.edu/~rubin/nacphy/lapack/codes/eigen-c.html)

and

compile it with g++ on cygwin on my windows 7 laptop, I am using the following command:

$ g++ eigen_complex.cpp -L G:\cygwin_root_dir\lib -lliblapack.a -llibblas.a

and getiing the following result:

eigen_complex.cpp: In function `int main()':
eigen_complex.cpp:41: error: `zgeev_' undeclared (first use this function)
eigen_complex.cpp:41: error: (Each undeclared identifier is reported only once for each function it appears in.)

I don't understand what is causing this error. Changing the name of the library from liblapack to lapack or to anything (say "lapa") does not make any difference to the error.The following compiling commands return the same result as above

g++ eigen_complex.cpp -L G:\cygwin_root_dir\lib -llapack.a -lblas.a
g++ eigen_complex.cpp -L G:\cygwin_root_dir\lib -llapack -lblas
g++ eigen_complex.cpp -L G:\cygwin_root_dir\lib -lliblapack -llibblas
g++ eigen_complex.cpp -lliblapack -llibblas

and

g++ eigen_complex.cpp -lliblapack -lxyz

also.I believe there is no library with name xyz and the compiler is not giving any warning about it.

Any help will be greatly appreciated.

解决方案

Hopefully adding this prototype in a header somewhere in your project should resolve it:

extern "C" void zgeev_(char*, char*,int*,double *, int*, struct complex [], struct complex [1][1], int*, struct complex [1][1], int*, struct complex [], int*, struct complex [], int*);

这篇关于将LAPACK库与cygwin上的g ++链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 21:55