我正在尝试编译一个简单的fortran hello world程序,使用f2py在python中调用。我使用的是Python 2.7,Python(X,Y),Spyder,Mingw64和Windows 7-64位。
这是我试图编译的fortran代码:
C File hello.f
subroutine foo (a)
integer a
print*, "Hello from Fortran!"
print*, "a=",a
end
我确保安装了numpy并从命令行识别f2py命令。我已经安装了mingw64并将“C:\ Python27 \ Scripts”和“C:\ mingw64 \ bin \”添加到我的系统环境路径中。我也“设置C_INCLUDE_PATH = C:\ mingw64 \ include”。
当我从命令行运行f2py时,出现以下错误。有谁知道如何让f2py成功运作?
C:\Users\jake\Desktop\jake_python>python C:\Python27\Scripts\f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -m hello hello.f
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\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.c
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7
Reading fortran codes...
Reading file 'hello.f' (format:fix,strict)
Post-processing...
Block: hello
Block: foo
Post-processing (stage 2)...
Building modules...
Building module "hello"...
Constructing wrapper function "foo"...
foo(a)
Wrote C/API module "hello" to file "c:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.c"
adding 'c:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.c' to sources.
adding 'c:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7' to include_dirs.
copying C:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7
copying C:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\jake\appdata\local\temp\tmpu1lmwg\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:\mingw64\bin\gfortran.exe
Found executable C:\mingw64\bin\gfortran.exe
customize Gnu95FCompiler using build_ext
building 'hello' extension
compiling C sources
C compiler: gcc -O2 -Wall -Wstrict-prototypes
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\Release
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg
creating c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7
compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -Ic:\users\jake\appdata\local\temp\tmpu1lmwg\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\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c c:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.c -o c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o
Found executable C:\mingw64\bin\gcc.exe
gcc -O2 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -Ic:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c c:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.c -o c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o
compiling Fortran sources
Fortran f77 compiler: C:\mingw64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops
Fortran f90 compiler: C:\mingw64\bin\gfortran.exe -Wall -g -fno-second-underscore -O3 -funroll-loops
Fortran fix compiler: C:\mingw64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O3 -funroll-loops
compile options: '-Ic:\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c'
gfortran.exe:f77: hello.f
C:\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\hello.o -LC:\mingw64\lib\gcc\x86_64-w64-mingw32\5.2.0 -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lgfortran -o .\hello.pyd
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x35): undefined reference to `__imp_PyNumber_Int'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x77): undefined reference to `__imp_PyComplex_Type'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x82): undefined reference to `__imp_PyType_IsSubtype'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0xa0): undefined reference to `__imp_PyErr_Occurred'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0xbb): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0xdc): undefined reference to `__imp_PyObject_GetAttrString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0xea): undefined reference to `__imp_PyErr_Clear'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x141): undefined reference to `__imp_PySequence_Check'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x154): undefined reference to `__imp_PySequence_GetItem'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x169): undefined reference to `__imp__Py_NoneStruct'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x1ae): undefined reference to `__imp_PyArg_ParseTupleAndKeywords'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x1f7): undefined reference to `__imp_PyErr_Occurred'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x219): undefined reference to `__imp_Py_BuildValue'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x255): undefined reference to `__imp_Py_InitModule4'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x25c): undefined reference to `__imp_PyType_Type'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x277): undefined reference to `__imp_PyImport_ImportModule'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x293): undefined reference to `__imp_PyObject_GetAttrString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x2ab): undefined reference to `__imp_PyCObject_Type'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x2b8): undefined reference to `__imp_PyExc_RuntimeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x2c6): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x2d4): undefined reference to `__imp_PyExc_ImportError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x2e3): undefined reference to `__imp_PyErr_Print'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x325): undefined reference to `__imp_PyCObject_AsVoidPtr'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x385): undefined reference to `__imp_PyErr_Occurred'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x391): undefined reference to `__imp_PyExc_ImportError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x3a9): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x3b5): undefined reference to `__imp_PyModule_GetDict'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x3bc): undefined reference to `__imp_PyString_FromString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x3d9): undefined reference to `__imp_PyDict_SetItemString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x40b): undefined reference to `__imp_PyErr_NewException'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4a5): undefined reference to `__imp_PyExc_RuntimeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4ae): undefined reference to `__imp_PyErr_Format'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4b5): undefined reference to `__imp_PyExc_ImportError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4bc): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4c8): undefined reference to `__imp_PyExc_ImportError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4d6): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4ee): undefined reference to `__imp_PyExc_RuntimeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4f7): undefined reference to `__imp_PyErr_Format'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x4fe): undefined reference to `__imp_PyExc_ImportError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x505): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x52c): undefined reference to `__imp_PyExc_AttributeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x53a): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x546): undefined reference to `__imp_PyExc_ImportError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x55b): undefined reference to `__imp_PyExc_RuntimeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x569): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o:hellomodule.c:(.text+0x575): undefined reference to `__imp_PyExc_ImportError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x3e): undefined reference to `__imp_PyObject_GetAttrString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x47): undefined reference to `__imp_PyErr_Clear'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x66): undefined reference to `__imp_PyString_FromString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x95): undefined reference to `__imp_PyString_AsString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xa5): undefined reference to `__imp_PyString_FromFormat'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xbf): undefined reference to `__imp_PyString_FromString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xf8): undefined reference to `__imp_PyMem_Free'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x703): undefined reference to `__imp_PyExc_TypeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x713): undefined reference to `__imp_PyErr_Format'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x721): undefined reference to `__imp_PyExc_RuntimeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x731): undefined reference to `__imp_PyErr_Format'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x764): undefined reference to `__imp_PyDict_GetItemString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x91f): undefined reference to `__imp_Py_FindMethod'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x93f): undefined reference to `__imp_PyString_FromString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xa2b): undefined reference to `__imp_PyString_ConcatAndDel'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xb43): undefined reference to `__imp_PyDict_SetItemString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xd67): undefined reference to `__imp__Py_NoneStruct'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xdef): undefined reference to `__imp_PyCObject_FromVoidPtr'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xe02): undefined reference to `__imp_PyDict_SetItemString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xf40): undefined reference to `__imp_PyDict_SetItemString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xf69): undefined reference to `__imp_PyErr_Occurred'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xf74): undefined reference to `__imp_PyErr_Print'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xf7a): undefined reference to `__imp_PyErr_Clear'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xfa2): undefined reference to `__imp__PyObject_New'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0xfb0): undefined reference to `__imp_PyDict_New'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1003): undefined reference to `__imp__PyObject_New'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1015): undefined reference to `__imp_PyDict_New'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x105c): undefined reference to `__imp_PyDict_SetItemString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1234): undefined reference to `__imp__Py_NoneStruct'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1299): undefined reference to `__imp_PyType_IsSubtype'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x175e): undefined reference to `__imp_PyExc_ValueError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x176a): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1907): undefined reference to `__imp_PyExc_TypeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1919): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1cc4): undefined reference to `__imp__Py_NoneStruct'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1dfa): undefined reference to `__imp_PyDict_SetItemString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1e2a): undefined reference to `__imp_PyDict_DelItemString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1e35): undefined reference to `__imp_PyExc_AttributeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1e49): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1ef2): undefined reference to `__imp_PyDict_New'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1f13): undefined reference to `__imp_PyExc_AttributeError'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1f27): undefined reference to `__imp_PyErr_SetString'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1fa3): undefined reference to `__imp_PyCObject_FromVoidPtr'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1fb3): undefined reference to `__imp_PyCObject_AsVoidPtr'
c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o:fortranobject.c:(.text+0x1fc3): undefined reference to `__imp_PyCObject_Type'
collect2.exe: error: ld returned 1 exit status
error: Command "C:\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\hellomodule.o c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\users\jake\appdata\local\temp\tmpu1lmwg\src.win32-2.7\fortranobject.o c:\users\jake\appdata\local\temp\tmpu1lmwg\Release\hello.o -LC:\mingw64\lib\gcc\x86_64-w64-mingw32\5.2.0 -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lgfortran -o .\hello.pyd" failed with exit status 1
答案 0 :(得分:1)
面对同样的问题,我通过创建新的导入库libpython27.a
解决了这个问题。为此,您需要安装pexports。然后从命令行写:
pexports C:\Windows\System32\python27.dll > C:SOME\TEMP\DIRECTORY\python27.def
一旦你有了这个,你需要使用dlltools来创建导入库。首先将目录更改为.def文件所在的目录,然后使用此命令..
dlltool –D python27.dll –d python.def –l libpython27.a
然后,您需要将此新的libpython27.a放在python安装目录Python27\libs
下的 libs 文件夹中。请注意,您可能会替换现有的libpython27.a文件。