thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

Gnu95FCompiler doesn't find libmingwex.a when using msvc + gfortran (Trac #2194) #5984

Open numpy-gitbot opened 12 years ago

numpy-gitbot commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2194 on 2012-07-30 by trac user stevenwinfield, assigned to atmention:cournape.

(This is actually a bug in 1.6.2, but I couldn't select that)

A MingW installation is laid out as follows:

MingW
| - lib
|   | - libmingw32.a
|   | - libmingwex.a
|   | - gcc
|       | - mingw32
|           | - <version number>
|               | - libgcc.a
| - mingw32
    | - lib
        | - ...

In numpy/distutils/fcompiler/gnu.py, in the get_library_dirs() method of Gnu95FCompiler (beginning line 299) the code first gets the libgcc directory then tries to navigate to the directory containing libmingwex.a by doing the following:

d = os.path.normpath(self.get_libgcc_dir())
root = os.path.join(d, os.pardir, os.pardir, os.pardir, os.pardir)
mingwdir = os.path.normpath(os.path.join(root, target, "lib"))

"target" here is "mingw32", so mingwdir is "MingW\mingw32\lib", which exists but doesn't contain libmingwex.a. If "target" were to be removed from the last line then all would be fine.

This problem manifests itself when trying to build scipy, with the error message:

LINK : fatal error LNK1181: cannot open input file 'mingw32.lib'

This is because a few MingW .a files are copied (by _libs_with_msvc_and_fortran() in numpy/distutils/command/build_ext.py) to .lib files in a temporary build directory so that they can be found by msvc - one of which should be libmingw32.a => mingw32.lib. However, the .a file is never found and so the copying never takes place.