0

Since I updated to Windows 10 and a clean install of Python xy on my 64Bit Windows 10 machine, I cannot compile f2py modules anymore.

F2py finds the gfortran compiler and apparently mingw32, but all efforts end up in errors and eventually ends up in error code 1:

U:\f2py Test>f2py fortran_sum.f90 -c --fcompiler=gnu95 --compiler=mingw32
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "untitled" sources
f2py options: []
f2py:> c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\untitledmodule.c
creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7
Reading fortran codes...
        Reading file 'fortran_sum.f90' (format:free)
Post-processing...
        Block: untitled
                        Block: fortran_sum
Post-processing (stage 2)...
Building modules...
        Building module "untitled"...
                Constructing wrapper function "fortran_sum"...
                  su = fortran_sum(a,b)
        Wrote C/API module "untitled" to file "c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\untitledmodule.c"
  adding 'c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\fortranobject.c' to sources.
  adding 'c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7' to include_dirs.
copying C:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7
copying C:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7
build_src: building npy-pkg config files
running build_ext
Cannot build msvcr library: "msvcr90d.dll" not found
customize Mingw32CCompiler
customize Mingw32CCompiler using build_ext
customize Gnu95FCompiler
Found executable C:\mingw32-xy\bin\gfortran.exe
Found executable C:\mingw32-xy\bin\gfortran.exe
customize Gnu95FCompiler using build_ext
building 'untitled' extension
compiling C sources
C compiler: gcc -O2 -Wall -Wstrict-prototypes

creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release
creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users
creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd
creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata
creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local
creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp
creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp\tmpu30_2r
creating c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7
compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -Ic:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c'
gcc -O2 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -Ic:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\untitledmodule.c -o c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\untitledmodule.o
Found executable C:\mingw32-xy\bin\gcc.exe
gcc -O2 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -Ic:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\fortranobject.c -o c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\fortranobject.o
compiling Fortran sources
Fortran f77 compiler: C:\mingw32-xy\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops
Fortran f90 compiler: C:\mingw32-xy\bin\gfortran.exe -Wall -g -fno-second-underscore -O3 -funroll-loops
Fortran fix compiler: C:\mingw32-xy\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O3 -funroll-loops
compile options: '-Ic:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c'
gfortran.exe:f90: fortran_sum.f90
C:\mingw32-xy\bin\gfortran.exe -Wall -g -Wall -g -shared c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\untitledmodule.o c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\fortranobject.o c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\fortran_sum.o -Lc:\mingw32-xy\lib\gcc\mingw32\4.5.2 -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lgfortran -o .\untitled.pyd
C:\Python27\libs/libpython27.a(dmmes00281.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00105.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes01026.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00712.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00054.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00220.o):(.idata$7+0x0): more undefined references to `_head_C__build27_cpython_PCBuild_libpython27_a' follow
collect2: ld returned 1 exit status
error: Command "C:\mingw32-xy\bin\gfortran.exe -Wall -g -Wall -g -shared c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\untitledmodule.o c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\users\username~1.hyd\appdata\local\temp\tmpu30_2r\src.win32-2.7\fortranobject.o c:\users\username~1.hyd\appdata\local\temp\tmpu30_2r\Release\fortran_sum.o -Lc:\mingw32-xy\lib\gcc\mingw32\4.5.2 -LC:\Python27\libs -LC:
\Python27\PCbuild -lpython27 -lgfortran -o .\untitled.pyd" failed with exit status 1

Here is the information from -c --help-fcompiler: Fortran compilers found: --fcompiler=gnu95 GNU Fortran 95 compiler (4.5.2)

On my old Python server the same fortran code compiles into a PYD which is usable, but not in my new environment. As the FORTRAN compiler can be found, the error has to be somewhere else. Any ideas?

Benjamin Mewes
  • 89
  • 2
  • 10
  • 2
    See [this](http://stackoverflow.com/a/32589305/6382074) answer. Not sure this will solve your problem but it may help? Note the easiest solution according to a comment there was to simply upgrade the python version. What is the exact version you're using? – d_1999 Aug 15 '16 at 14:17
  • That was it! What a struggle! Many thanks and a virtual beer for you! – Benjamin Mewes Aug 15 '16 at 14:32

0 Answers0