如何使用CMake获取基本的Fortran文件以在Windows / MinGW上进行编译? [英] How can I get a basic Fortran file to compile on Windows/MinGW using CMake?

查看:332
本文介绍了如何使用CMake获取基本的Fortran文件以在Windows / MinGW上进行编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得让CMake在Windows上运行完全迷失了。我有一个包含Fortran和C文件的项目( ECCODE )。如果不使用CMake,我可以编译Fortran文件。但是该项目附带了大量的CMake文件。我看到下面的错误,它对我说: 我(CMake)无法编译简单的Fortran程序,即使您在不使用CMake时也可以编译Fortran文件。 任何人都可以理解吗?这个的?我正在尝试使用mingw64,因为我无法在Windows构建的该项目上使用cygwin。在Mac OS X和GNU / Linux上,一切正常,但是我必须在Windows上运行此项目...

I feel completely lost trying to get CMake to work on Windows. I have a project (ECCODES) that has Fortran and C files. I can compile Fortran files if I don't use CMake. But this project came with a ton of CMake files. I look at the error below and it says to me, "I (CMake) cannot compile a simple Fortran program even though you can compile Fortran files when you aren't using CMake." Can anyone make sense of this? I'm trying to use mingw64 since I can't use cygwin on this project for the Windows build. On Mac OS X and GNU/Linux everything builds fine, but I have to run this project on 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.


推荐答案

之前,我使用的是 tdm-gcc 的Windows 64位版本gfortran 。我通过 Simply Fortran 切换到 gfortran 的64位版本,现在整个 ECCODES 项目都可以使用CMake构建完成。我仍在使用MingW64 gcc 来编译C文件。

Before, I was using the tdm-gcc Windows 64-bit build of gfortran. I switched to the 64-bit build of gfortran by Simply Fortran, and now the entire ECCODES project builds to completion using CMake. I'm still using MingW64 gcc to compile the C files.

关于 John Wasilewski的提示href = https://www.physicsforums.com/threads/best-fortran-compiler-for-windows-7.465593/ rel = nofollow>物理论坛线程,他提供了有关Simply Fortran的技巧。

Hat tip to John Wasilewski on a thread of Physics Forums who gave the tip about Simply Fortran.

这篇关于如何使用CMake获取基本的Fortran文件以在Windows / MinGW上进行编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆