问题
So lately I've been learning an absolute stack about how programming and compiling and stuff works, but this is a little out of my depth. Currently, I'm trying to install pyigrf12 so that I have some way of using the IGRF in Python (where I do most of my work). My first issue was, because this model was developed in Fortran, finding a suitable compiler. I used MinGW to install both g77 and gfortran among other things.
Each compiler gives me different errors. When setup.py defaulted to using g77, I got "failed with exit status 1" due to "Invalid form for assignment..." errors a few times during the process. So I renamed the g77.exe binary so that setup.py was forced to use gfortran.exe (I'm unsure of how to specify which compiler to use, this is all command line).
This compiler got further through the process, but eventually terminated with a "failed with exit status 1112". Looking through the output, the compiler seems to have encountered "fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'". Googling this error, I came across several forums with reference to this issue. The proposed solution in each case seemed to assume I was using a Visual Studio environment, and things could be clicked to change a '/MACHINE:IX86' flag.
This seems simple enough, but is this able to be done in the command line? If so, how? Currently all I do to run the setup.py script is
python setup.py develop
in the command prompt (I'm on a Windows machine). Any help would be greatly appreciated!
EDIT: The entire output of what I write is below. Note that I haven't made any changes to anything - the only thing I've had control over so far is the compilers. Everything else is part of pyigrf. While it definitely seems like it might be some problem in the compilation of this module, I was wondering if there was any way around it. Since it seems like it's a flag of some sort... I'm not sure. Honestly hoping for some kind of miracle. Here it is:
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'
回答1:
From the log it appears to me that you installed a 32-bit version of gfortran. You need a 64-bit version to be compatible with the rest of your toolchain.
To be sure execute: gfortran -v
and check the version information.
来源:https://stackoverflow.com/questions/47105737/python-module-with-fortran-lnk1112-module-machine-type-x86-conflicts-with-ta