PDL::LinearAlgebra-0.30 can't find lapack library on strawberry perl 5.28.2.1 32bit/64bit
aero opened this issue · 6 comments
Hi
From reported mail....
As you may see in the current Makefile.PL (https://github.com/PDLPorters/pdl-linearalgebra/blob/master/Makefile.PL#L10-L26), it depends on finding pkgconfig information for both BLAS and LAPACK.
I have just discovered that Strawberry Perl PDL edition has LAPACK supplied, which I did not know. It supplies pkgconfig (at least on 5.32) for BLAS and LAPACK, and I have just successfully installed PDL:LA on 5.32.
strawberry perl 5.28 also has both lapack.pc and blas.pc
blas.pc
prefix=${pcfiledir}/../..
libdir=${prefix}/lib
Name: BLAS
Description: FORTRAN reference implementation of BLAS Basic Linear Algebra Subprograms
Version: 3.7.0
URL: http://www.netlib.org/blas/
Libs: -L${libdir} -lblas -lgfortran -lquadmath
Libs.private: -lm
lapack.pc
prefix=${pcfiledir}/../..
libdir=${prefix}/lib
Name: LAPACK
Description: FORTRAN reference implementation of LAPACK Linear Algebra PACKage
Version: 3.7.0
URL: http://www.netlib.org/lapack/
Libs: -L${libdir} -llapack -lblas -lgfortran -lquadmath
Requires: blas
Can you do “cpanm –look PDL::LinearAlgebra”, then “perl Makefile.PL” on there, and open an issue on https://github.com/PDLPorters/pdl-linearalgebra/issues with the output and any other information that you think will help? It would be very helpful if you could first edit the Makefile.PL to add “debug=>1” to the flags for checklib_or_exit.
>perl Makefile.PL
Loaded ExtUtils::F77 version 1.26
ExtUtils::F77: Unable to guess and/or validate system/compiler configuration
ExtUtils::F77: Will try system=MinGW Compiler=GFortran
# Compiler seems to be C:\strawberry-perl-5.28-32bit\c\bin\gcc.exe
# C:\strawberry-perl-5.28-32bit\c\bin\gcc.exe -s -O2 -DWIN32 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields assertlibaBCczgBg.c -s -L"C:\strawberry-perl-5.28-32bit\perl\lib\CORE" -L"C:\strawberry-perl-5.28-32bit\c\lib" -o assertlibZVNCvoKs.exe
# C:\strawberry-perl-5.28-32bit\c\bin\gcc.exe -s -O2 -DWIN32 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields assertlibFwYyzzSx.c -s -L"C:\strawberry-perl-5.28-32bit\perl\lib\CORE" -L"C:\strawberry-perl-5.28-32bit\c\lib" -o assertlib75WjBG17.exe
# C:\strawberry-perl-5.28-32bit\c\bin\gcc.exe -s -O2 -DWIN32 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields assertlibjrydGNOz.c -s -L"C:\strawberry-perl-5.28-32bit\perl\lib\CORE" -L"C:\strawberry-perl-5.28-32bit\c\lib" -o assertlibCMJlBpr2.exe
# C:\strawberry-perl-5.28-32bit\c\bin\gcc.exe -s -O2 -DWIN32 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields assertlibamoSgTHO.c -LC:/strawberry-perl-5.28-32bit/c/bin/../lib/gcc/i686-w64-mingw32/7.1.0 -L/usr/lib -llapack -s -L"C:\strawberry-perl-5.28-32bit\perl\lib\CORE" -L"C:\strawberry-perl-5.28-32bit\c\lib" -o assertlib43yiqXMF.exe
C:\strawberry-perl-5.28-32bit\c\lib/liblapack.a(iparam2stage.F.obj):(.text+0x185): undefined reference to `_gfortran_compare_string'
collect2.exe: error: ld returned 1 exit status
Can't link/include C library 'lapack', aborting.
My suspicion is that 5.28 didn’t have a separate BLAS pkgconfig, and that changing Makefile.PL line 9 to remove the “blas” will make it work. If you could try that too, that would really help! If that’s the problem, it’s easily made conditional.
I removed "blas" but got the same error.
With PDL::LinearAlgebra 0.26 and strawberry perl 5.28, It doesn't have the problem and started to failed from ver. 0.27.
See http://matrix.cpantesters.org/?dist=PDL-LinearAlgebra%200.26;os=mswin32;perl=5.28.2;reports=1
It seems from this that, quite reasonably, LAPACK wants all its libs as specified in the pkg-config
files. Unfortunately, Devel::CheckLib is being overly clever, but getting it wrong. In particular, I've tried the LIBS
option, but the library misparses that.
Could you try replacing these lines:
# work around Devel::CheckLib not doing Text::ParseWords::shellwords
use Text::ParseWords qw(shellwords);
my @libpath = map {my $r=$_;$r=~s/^-L//?$r:()} shellwords $libs0;
my $f77_uscore = (ExtUtils::F77->trail_ ? '_' : '');
check_lib_or_exit(
lib => 'lapack',
libpath => \@libpath,
header => [($^O =~ /MSWin/ ? 'float.h' : ()), qw(stdio.h math.h)],
with:
# work around Devel::CheckLib not doing Text::ParseWords::shellwords
use Text::ParseWords qw(shellwords);
my @libpath = map {my $r=$_;$r=~s/^-L//?$r:()} my @sw = shellwords $libs0;
my @lib = map {my $r=$_;$r=~s/^-l//?$r:()} @sw;
my $mangled_libs0 = join ' ', (map qq{-L"$_"}, @libpath), (map "-l$_", @lib);
my $f77_uscore = (ExtUtils::F77->trail_ ? '_' : '');
check_lib_or_exit(
ldflags => $mangled_libs0,
header => [($^O =~ /MSWin/ ? 'float.h' : ()), qw(stdio.h math.h)],
and seeing if that works?
This would all be easier if mattn/p5-Devel-CheckLib#34 got merged and released.
In breaking news, that PR actually has been merged and released! However, @aero I still need to know whether the above change fixes the issue on your platform :-)
In breaking news, that PR actually has been merged and released! However, @aero I still need to know whether the above change fixes the issue on your platform :-)
Thanks.
Your above work around also works well. ' ')b
Thank you for the feedback! I've released this as 0.31, but due to my misreading the CI results, it's actually broken MacOS, so there will (hopefully) soon be a 0.32 which fixes this.