1
Fortranコードに印刷または関数呼び出しが含まれている場合、FortranをPython拡張モジュールにコンパイルする際に問題があります。F2PYで印刷または書き込みでFortranをコンパイルできません
gfortran(mingw-w64経由)とPython 2.7用MSVCコンパイラがインストールされたWindows 8.1です。使用しているPythonディストリビューションはAnacondaです。
test.f
subroutine test (a)
integer, intent(out) :: a
print *,"Output from test"
a = 10
end subroutine test
はf2py -c -m --fcompiler=gnu95 test test.f90
実行私はこれらのエラーを参照してください。
test.o : error LNK2019: unresolved external symbol _gfortran_st_write referenced in function test_
test.o : error LNK2019: unresolved external symbol _gfortran_transfer_character_write referenced in function test_
test.o : error LNK2019: unresolved external symbol _gfortran_st_write_done referenced in function test_
.\test.pyd : fatal error LNK1120: 3 unresolved externals
をしかし、私は、印刷(または書き込み)の文をコメントアウトするとき、それが正常に動作します。
私が気づいた奇妙なことは、PythonをArcGIS用に使用しているようだということです。
compile options: '-Ic:\users\[username]\appdata\local\temp\tmpqiq6ay\src.win-amd64-
2.7 -IC:\Python27\ArcGISx6410.3\lib\site-packages\numpy\core\include -IC:\Python
27\ArcGISx6410.3\include -IC:\Python27\ArcGISx6410.3\PC -c'
gfortran.exe:f90: test.f90
ご協力いただければ幸いです。
gfortranランタイムライブラリ(libgfortran)を正しくリンクしていません。なぜ '--fcompiler = gnu95'を使うのですか? –