如何使用CMake在Windows / MinGW上编译基本的Fortran文件?

时间:2016-04-25 02:05:24

标签: cmake gfortran clion

我觉得完全失败,试图让CMake在Windows上工作。我有一个包含Fortran和C文件的项目(ECCODES)。如果我不使用CMake,我可以编译Fortran文件。但是这个项目附带了大量的CMake文件。我看看下面的错误,它告诉我,“我(CMake)无法编译一个简单的Fortran程序,即使你可以在不使用CMake时编译Fortran文件。”任何人都可以理解这个的?我正在尝试使用mingw64,因为我无法在此项目中使用cygwin进行Windows构建。在Mac OS X和GNU / Linux上,一切都很好,但我必须在Windows上运行这个项目......

Error:The Fortran compiler "c:/gcc-5.1.0-tdm64-1-fortran/bin/gfortran.exe" is not able to compile a simple test program.
It fails with the following output:
 Change Dir: C:/Users/knauthg/.CLion2016.1/system/cmake/generated/ECCodes-45f4e5f3/45f4e5f3/__default__/CMakeFiles/CMakeTmp
Run Build Command:"C:/mingw64/bin/mingw32-make.exe" "cmTC_93cb8/fast"
C:/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_93cb8.dir\build.make CMakeFiles/cmTC_93cb8.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/knauthg/.CLion2016.1/system/cmake/generated/ECCodes-45f4e5f3/45f4e5f3/__default__/CMakeFiles/CMakeTmp'
Building Fortran object CMakeFiles/cmTC_93cb8.dir/testFortranCompiler.f.obj
c:\gcc-5.1.0-tdm64-1-fortran\bin\gfortran.exe -c C:\Users\knauthg\.CLion2016.1\system\cmake\generated\ECCodes-45f4e5f3\45f4e5f3\__default__\CMakeFiles\CMakeTmp\testFortranCompiler.f -o CMakeFiles\cmTC_93cb8.dir\testFortranCompiler.f.obj
CMakeFiles\cmTC_93cb8.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_93cb8.dir/testFortranCompiler.f.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_93cb8.dir/testFortranCompiler.f.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/knauthg/.CLion2016.1/system/cmake/generated/ECCodes-45f4e5f3/45f4e5f3/__default__/CMakeFiles/CMakeTmp'
Makefile:125: recipe for target 'cmTC_93cb8/fast' failed
mingw32-make.exe: *** [cmTC_93cb8/fast] Error 2
CMake will not be able to correctly generate this project.

1 个答案:

答案 0 :(得分:0)

之前,我正在使用gfortran的{​​{3}} Windows 64位版本。gfortran。我通过tdm-gcc切换到gcc的64位版本,现在整个Simply Fortran项目使用CMake构建完成。我还在使用MingW64 info: component: Service Name 来编译C文件。

向约翰·瓦西莱夫斯基致敬,ECCODES给了关于Simply Fortran的提示。