2017-05-03 56 views
1

我正在尝试将LAPACK合并到我正在编译的程序中。我目前在MINGW64 gfortran编译器中使用msys2工具链。我使用以下过程来获得LAPACK:与MINGW64一起使用LAPACK

To get BLAS and LAPACK together 
In Msys2 64 bit environment type in: 
Pacman –S mingw-w64-x86_64-cmake #gets cmake 
Pacman –S git #gets git 
Git clone https://github.com/msys2/MINGW-packages.git 
Cd MINGW-packages/mingw-w64-lapack 

Then navigate to ~/MINGW-packages/mingw-w64-lapack and open the file called PKGBUILD. Do a find and replace all from ‘RESPOSE’ to ‘RESPONSE’. Save the file and exit the text editor. 

In the msys environment, type: 
Makepkg-mingw 
Pacman –U mingw-w64-x86_64-lapack*.pkg.tar.gz 

BLAS and LAPACK are now installed. 

To test lapack, do the following. 

> cd ~ 
> wget http://www.math.ucla.edu/~wotaoyin/software/lapack_test.cpp # download 
> g++ lapack_test.cpp -llapack -o lapack_test  # build 
> ./lapack_test         # run 

然后我尝试使用LAPACK编译程序。我的程序只调用sgetrf和sgetrs。然而,当我编译我收到以下错误:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetrf.f.obj):(.text+0x43a): undefined reference to `strsm_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetrf.f.obj):(.text+0x524): undefined reference to `sgemm_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetrs.f.obj):(.text+0x159): undefined reference to `strsm_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetrs.f.obj):(.text+0x1c5): undefined reference to `strsm_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetrs.f.obj):(.text+0x340): undefined reference to `strsm_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetrs.f.obj):(.text+0x3ac): undefined reference to `strsm_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetf2.f.obj):(.text+0x1c3): undefined reference to `isamax_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetf2.f.obj):(.text+0x212): undefined reference to `sswap_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetf2.f.obj):(.text+0x36c): undefined reference to `sger_' 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap 
ack.a(sgetf2.f.obj):(.text+0x3ca): undefined reference to `sscal_' 
collect2.exe: error: ld returned 1 exit status 
make[1]: *** [Makefile.all:20: avl] Error 1 

我在链接liblapack.a缺少什么?

我的命令是:

gfortran -m64 -o avl avl.o aoper.o amode.o amass.o asetup.o amake.o ainput.o 
aoutput.o aero.o atrim.o atpforc.o aic.o cdcl.o airutil.o autil.o aplotvl.o aplo 
ttp.o aplotmd.o limits.o pltops.o hidden.o plsubs.o userio.o plutil.o arrow3d.o 
getvm.o matrix.o spline.o sgutil.o second.o -static ../plotlib/libPlt_mingwSP.a 
../eispack/libeispack.a -lgdi32 -luser32 -lblas -llapack 

回答

0

我想回答我的问题,因为我相信我发现的错误。

首先,它看起来像这些调用与BLAS有关。所以我需要添加-lblas来编译调用。然而,我最初尝试这个没有任何效果,然后在-llapack调用后调用了-lblas,并且它工作正常。

+0

请参阅[为什么库链接的顺序有时会导致GCC出错?](http://stackoverflow.com/q/45135/1362568) –