Linking LAPACK library with g++ on cygwin

北战南征 提交于 2019-12-14 03:54:49

问题


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.


回答1:


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*);


来源:https://stackoverflow.com/questions/13891423/linking-lapack-library-with-g-on-cygwin

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