Subject: | gfortran having a .so file instead of .a is not found |
On some systems there is a libgfortran.so file but no libgfortran.a file. Since the link_gnufortran_compiler subroutine only looks for libgfortran.a it doesn't find the library. Then it tries -lf2c, fails, and falls back to f77 which probably isn't present.
In the attached patch I've copied the test for .a files so that it tries again for .so files. I did it that way so that it would keep the same behavior as before in the case of systems where libgfortran.a is present.
Subject: | 0001-Add-check-for-GNU-fortran-.so-files-as-well-as-.a.patch |
From 883f88237885366d5146f2f6045200725f8e4e6d Mon Sep 17 00:00:00 2001
From: Graham Bell <g.bell@jach.hawaii.edu>
Date: Mon, 25 Nov 2013 16:46:33 -1000
Subject: [PATCH] Add check for GNU fortran .so files as well as .a.
---
F77.pm | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/F77.pm b/F77.pm
index 6d35e80..a28ea49 100644
--- a/F77.pm
+++ b/F77.pm
@@ -727,10 +727,20 @@ sub link_gnufortran_compiler {
$dir =~ s,/lib$lib.a$,,;
last;
} else {
+ # Try the same thing again but looking for the .so file
+ # rather than the .a file.
+ $dir = `$compiler -print-file-name=lib$test.so`;
+ chomp $dir;
+ if (defined $dir && $dir ne "lib$test.so") {
+ $lib = $test; # Found an existing library
+ $dir =~ s,/lib$lib.so$,,;
+ last;
+ } else {
$dir = "/usr/local/lib";
$lib = "f2c";
}
}
+ }
return( "-L$dir -L/usr/lib -l$lib -lm" );
}
--
1.7.1