Windows上的f2py:未定义的引用

时间:2018-06-08 13:02:14

标签: python windows fortran f2py

我尝试在Windows上使用f2py编译一个简单的Hello_World.f90程序但是获得了大量未定义的引用

第一个错误是: C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `import_array': C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1466: undefined reference to `_imp__PyImport_ImportModule'

有几个相同类型的跟随错误。

我尝试将-D MS_WIN64添加到compiler_so中的编译器参数cygwinccompiler.py(来自Python: undefined reference to `_imp __Py_InitModule4'),但这并没有帮助。

我该如何解决这个问题?

部分输出如下:

c:\Users\KB\Fortran_Routines>python C:\Users\KB\Python\python-3.4.4.amd64\Scripts\f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m hello hello.f90 
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 "hello" sources
f2py options: []
f2py:> C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.c
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4
Reading fortran codes...
    Reading file 'hello.f90' (format:free)
Post-processing...
    Block: hello
            Block: mod_hello
                Block: hello
Post-processing (stage 2)...
    Block: hello
        Block: unknown_interface
            Block: mod_hello
                Block: hello
Building modules...
    Building module "hello"...
        Constructing F90 module support for "mod_hello"...
            Constructing wrapper function "mod_hello.hello"...
              hello(a)
    Wrote C/API module "hello" to file "C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.c"
    Fortran 90 wrappers are saved to "C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hello-f2pywrappers2.f90"
  adding 'C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\fortranobject.c' to sources.
  adding 'C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4' to include_dirs.
copying C:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\f2py\src\fortranobject.c -> C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4
copying C:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\f2py\src\fortranobject.h -> C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4
  adding 'C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hello-f2pywrappers2.f90' to sources.
build_src: building npy-pkg config files
running build_ext
customize Mingw32CCompiler
customize Mingw32CCompiler using build_ext
customize Gnu95FCompiler
Found executable C:\MinGW\bin\gfortran.exe
customize Gnu95FCompiler using build_ext
building 'hello' extension
compiling C sources
C compiler: gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes

creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4
compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1600 -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c'
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1600 -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.c -o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1600 -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\fortranobject.c -o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\fortranobject.o
compiling Fortran 90 module sources
Fortran f77 compiler: C:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops
Fortran f90 compiler: C:\MinGW\bin\gfortran.exe -Wall -g -fno-second-underscore -O3 -funroll-loops
Fortran fix compiler: C:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O3 -funroll-loops
compile options: '-IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c'
extra options: '-JC:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\ -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\'
gfortran.exe:f90: hello.f90
compiling Fortran sources
Fortran f77 compiler: C:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops
Fortran f90 compiler: C:\MinGW\bin\gfortran.exe -Wall -g -fno-second-underscore -O3 -funroll-loops
Fortran fix compiler: C:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O3 -funroll-loops
compile options: '-IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c'
extra options: '-JC:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\ -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\'
gfortran.exe:f90: C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hello-f2pywrappers2.f90
C:\MinGW\bin\gfortran.exe -Wall -g -Wall -g -shared C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\fortranobject.o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\hello.o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hello-f2pywrappers2.o -Lc:\mingw\lib\gcc\mingw32\6.3.0 -LC:\Users\KB\Python\python-3.4.4.amd64\libs -LC:\Users\KB\Python\python-3.4.4.amd64\PCbuild\amd64 -lmsvcr71 -lpython34 -lgfortran -o .\hello.pyd
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `import_array':
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1466: undefined reference to `_imp__PyImport_ImportModule'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1470: undefined reference to `_imp__PyExc_ImportError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1470: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1473: undefined reference to `_imp__PyObject_GetAttrString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1476: undefined reference to `_imp__PyExc_AttributeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1476: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1481: undefined reference to `_imp__PyCapsule_Type'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1482: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1482: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1486: undefined reference to `_imp__PyCapsule_GetPointer'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1497: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1497: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1503: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1503: undefined reference to `_imp__PyErr_Format'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1509: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1509: undefined reference to `_imp__PyErr_Format'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1521: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1521: undefined reference to `_imp__PyErr_Format'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1532: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1532: undefined reference to `_imp__PyErr_Format'
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `try_pyarr_from_int':
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:130: undefined reference to `_imp__PyType_IsSubtype'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:130: undefined reference to `_imp__PyObject_Print'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:130: undefined reference to `_imp__PyLong_FromLong'
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `int_from_pyobj':
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:136: undefined reference to `_imp__PyLong_AsLong'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:139: undefined reference to `_imp__PyNumber_Long'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:141: undefined reference to `_imp__PyLong_AsLong'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:145: undefined reference to `_imp__PyComplex_Type'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:145: undefined reference to `_imp__PyComplex_Type'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:145: undefined reference to `_imp__PyType_IsSubtype'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:146: undefined reference to `_imp__PyObject_GetAttrString'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:149: undefined reference to `_imp__PySequence_Check'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:150: undefined reference to `_imp__PySequence_GetItem'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:152: undefined reference to `_imp__PyErr_Clear'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:157: undefined reference to `_imp__PyErr_Occurred'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:159: undefined reference to `_imp__PyErr_SetString'
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `f2py_rout_hello_mod_hello_hello':
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:197: undefined reference to `_imp___Py_NoneStruct'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:204: undefined reference to `_imp__PyArg_ParseTupleAndKeywords'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:218: undefined reference to `_imp__PyErr_Occurred'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:230: undefined reference to `_imp__Py_BuildValue'
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `PyInit_hello':
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:315: undefined reference to `_imp__PyModule_Create2'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:319: undefined reference to `_imp__PyType_Type'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:320: undefined reference to `_imp__PyErr_Print'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:320: undefined reference to `_imp__PyExc_ImportError'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:320: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:321: undefined reference to `_imp__PyErr_Occurred'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:322: undefined reference to `_imp__PyExc_ImportError'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:322: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:323: undefined reference to `_imp__PyModule_GetDict

0 个答案:

没有答案