The AC_F77_LIBRARY_LDFLAGS macro queries the fortran compiler for its link line in an effort to compute which flags would need to be added to a C++ link line in order to be able to link both C++ and Fortran files into the same program. However, of course the fortran link line contains not only the fortran intrinsic libraries, but also other compiler and libc runtime libraries. To deal with this, the macro contains a filter list of such undesired libraries. This filter list did not have any cases for mingw. As a result, these libraries would end up on the link line. This presents a problem further down the line when libtool attempts to verify that said libraries are indeed proper shared libraries (which they are not in general - some are static archives that shim various API differences). An example error message is:
``` [14:12:52] *** Warning: linker path does not have real file for library -lmingw32. [14:12:52] *** I have the capability to make that library automatically link in when [14:12:52] *** you link to this library. But I can only do this if you have a [14:12:52] *** shared version of the library, which you do not appear to have [14:12:52] *** because I did check the linker path looking for a file starting [14:12:52] *** with libmingw32 and none of the candidates passed a file format test [14:12:52] *** using a file magic. Last file checked: /opt/x86_64-w64-mingw32/x86_64-w64-mingw32/sys-root/lib/libmingw32.a ``` And similar for `-lmoldname` and `-lmingwex`. I've seen many references to this error on the internet, though usually people just give up, since this root cause is non-obvious. Hopefully fixing it here (and dropping the error message above), will help people avoid wasting some time in the future when trying to compile a project that happens to use these macros. Signed-off-by: Keno Fischer <k...@juliacomputing.com> --- lib/autoconf/fortran.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4 index d393c669..8d682152 100644 --- a/lib/autoconf/fortran.m4 +++ b/lib/autoconf/fortran.m4 @@ -665,10 +665,10 @@ while test $[@%:@] != 1; do -lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -little \ |-LANG:=* | -LIST:* | -LNO:* | -link) ;; - -lkernel32) + -lkernel32 | -lmingw* | -lmoldname) # Ignore this library only on Windows-like systems. case $host_os in - cygwin* | msys* ) ;; + cygwin* | msys* | *mingw*) ;; *) _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, , ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg") -- 2.25.1