2017-11-03 93 views
1

所以最近我一直在學習關於編程和編譯以及東西如何工作的絕對堆棧,但這是一個小問題我的深度。目前,我正在嘗試安裝pyigrf12,這樣我就可以在Python中使用IGRF(我在這裏完成大部分工作)。我的第一個問題是,因爲這個模型是在Fortran中開發的,所以找到了合適的編譯器。我用MinGW來安裝g77和gfortran等等。Python模塊與Fortran:LNK1112`模塊機器類型'X86'與目標機器類型'x64'衝突

每個編譯器都給我提供了不同的錯誤。當setup.py默認使用g77時,由於過程中出現了「無效的賦值形式...」錯誤,我得到了「失敗並退出狀態1」。所以我重命名了g77.exe二進制文件,以便setup.py被強制使用gfortran.exe(我不確定如何指定使用哪個編譯器,這是所有的命令行)。

該編譯器進一步完成了該過程,但最終以「失敗並退出狀態1112」結束。通過查看輸出,編譯器似乎遇到了「致命錯誤LNK1112:模塊機器類型'X86'與目標機器類型'x64''衝突。谷歌搜索這個錯誤,我遇到了幾個論壇參考這個問題。 proposed solution in each case似乎認爲我正在使用Visual Studio環境,並且可以單擊以更改'/ MACHINE:IX86'標誌。

這似乎很簡單,但是這能夠在命令行中完成嗎?如果是這樣,怎麼樣?目前,所有我做的運行setup.py腳本

python setup.py develop 
在命令提示符(我在Windows計算機上)

。任何幫助將不勝感激!

編輯:我寫的東西的全部輸出如下。請注意,我沒有對任何內容做任何修改 - 迄今爲止,我唯一能夠控制的就是編譯器。其他一切都是pyigrf的一部分。雖然看起來這可能是編譯本模塊時出現的一些問題,但我想知道是否有辦法解決這個問題。因爲它好像是某種標誌......我不確定。老實說希望有某種奇蹟。這裏是:

running develop 
running build_scripts 
running egg_info 
running build_src 
build_src 
building extension "igrf12" sources 
f2py options: ['--quiet'] 
    adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7\fortranobject.c' to sources. 
    adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7' to include_dirs. 
build_src: building npy-pkg config files 
writing requirements to pyigrf12.egg-info\requires.txt 
writing pyigrf12.egg-info\PKG-INFO 
writing top-level names to pyigrf12.egg-info\top_level.txt 
writing dependency_links to pyigrf12.egg-info\dependency_links.txt 
reading manifest file 'pyigrf12.egg-info\SOURCES.txt' 
writing manifest file 'pyigrf12.egg-info\SOURCES.txt' 
running build_ext 
customize MSVCCompiler 
customize MSVCCompiler using build_ext 
customize GnuFCompiler 
Could not locate executable g77 
Could not locate executable f77 
customize IntelVisualFCompiler 
Could not locate executable ifort 
Could not locate executable ifl 
customize AbsoftFCompiler 
Could not locate executable f90 
customize CompaqVisualFCompiler 
Could not locate executable DF 
customize IntelItaniumVisualFCompiler 
Could not locate executable efl 
customize Gnu95FCompiler 
Found executable D:\MinGW\bin\gfortran.exe 
customize Gnu95FCompiler 
customize Gnu95FCompiler using build_ext 
building 'igrf12' extension 
compiling C sources 
C:\Users\XXXXX\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7 -IC:\ProgramData\Anaconda2\lib\site-packages\numpy\core\include -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC /Tcbuild\src.win-amd64-2.7\igrf12module.c /Fobuild\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\igrf12module.obj 
C:\Users\XXXXX\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7 -IC:\ProgramData\Anaconda2\lib\site-packages\numpy\core\include -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC /Tcbuild\src.win-amd64-2.7\build\src.win-amd64-2.7\fortranobject.c /Fobuild\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\build\src.win-amd64-2.7\fortranobject.obj 
compiling Fortran sources 
Fortran f77 compiler: D:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O0 
Fortran f90 compiler: D:\MinGW\bin\gfortran.exe -Wall -g -fno-second-underscore -O0 
Fortran fix compiler: D:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O0 
compile options: '-Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7 -IC:\ProgramData\Anaconda2\lib\site-packages\numpy\core\include -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC -c' 
gfortran.exe:f77: fortran/igrf12.f 
C:\Users\XXXXX\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:d:\mingw\lib\gcc\mingw32\6.3.0 /LIBPATH:d:\mingw\lib /LIBPATH:C:\ProgramData\Anaconda2\libs /LIBPATH:C:\ProgramData\Anaconda2\PCbuild\amd64 /LIBPATH:C:\ProgramData\Anaconda2\PC\VS9.0\amd64 /LIBPATH:C:\ProgramData\Anaconda2\libs /LIBPATH:C:\ProgramData\Anaconda2\PCbuild\amd64 /LIBPATH:C:\ProgramData\Anaconda2\PC\VS9.0\amd64 /EXPORT:initigrf12 build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\igrf12module.obj build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\build\src.win-amd64-2.7\fortranobject.obj build\temp.win-amd64-2.7\Release\fortran\igrf12.o /OUT:igrf12.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\igrf12.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\igrf12.pyd.manifest 
build\temp.win-amd64-2.7\Release\fortran\igrf12.o : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' 
+0

忘記g77。卸載它以確保它不會干擾該過程。它完全**已經過時,從錯誤消息中可以明顯看出它不適用於該代碼。 –

+0

代碼的一部分編譯爲32位,另一部分編譯爲64位。你必須使這兩種類型。如果您打算使用大型數據集,最好使用64位。看到更多的輸出,而不僅僅是你選擇的幾個比特將是有益的。請注意,該標誌將有所不同,gfortran不接受Visual C++標誌。 –

+0

被編輯爲包含整個輸出。 – Yoshi

回答

1

從日誌中看來,你安裝了一個32位版本的gfortran。您需要一個64位版本來與您的工具鏈的其餘部分兼容。

確定執行:gfortran -v並檢查版本信息。

+0

它說「線程模型:win32」,所以我想這是一個32位版本?我在哪裏可以找到64位版本的gfortran? – Yoshi

+0

在與所有其他版本相同的地方https://gcc.gnu.org/wiki/GFortranBinaries#Windows –

+0

不,64位版本也說「線程模型:win32」。 gfortran -v調用32位系統i686和64位系統x86_64。在一個理想的世界中,信息將在COMPILER_OPTIONS()字符串中,但它不適用於gfortran。這個單行程序打印出任何f2003編譯器的位數:使用ISO_C_BINDING; print'(*(g0))',bit_size(0_C_INTPTR_T),'bits'; end – user5713492

相關問題