[英]The MinGW gfortran compiler is not able to compile a simple test program
在这篇文章之后,我正在尝试使用 MinGW 编译器在 Windows 上编译Elmer FEM 。 但是在运行时
cmake -DCMAKE_C_COMPILER=C:\\MinGW\\bin\\gcc.exe -DCMAKE_CXX_COMPILER=C:\\MinGW\\bin\\g++.exe -DCMAKE_Fortran_COMPILER=C:\\MinGW\\bin\\gfortran.exe ..
在build
文件夹中的命令我得到错误:
-- Selecting Windows SDK version 10.0.17134.0 to target Windows 10.0.18363.
-- The Fortran compiler identification is unknown
-- Check for working Fortran compiler: C:\MinGW\bin\gfortran.exe
-- Check for working Fortran compiler: C:\MinGW\bin\gfortran.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/CMakeTestFortranCompiler.cmake:45 (message):
The Fortran compiler
"C:\MinGW\bin\gfortran.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/foobar/Desktop/elmer/elmerfem/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/devenv.com CMAKE_TRY_COMPILE.sln /build Debug /project cmTC_8d573 &&
Microsoft Visual Studio 2017 Version 15.0.28010.2050.
Copyright (C) Microsoft Corp. All rights reserved.
Some errors occurred during migration. For more information, see the migration report:
C:\Users\foobar\Desktop\elmer\elmerfem\build\CMakeFiles\CMakeTmp\UpgradeLog.htm
Invalid project
从这里我尝试添加
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
到CmakeLists.txt
文件,从这里以管理员身份运行cmd
,然后从这里尝试卸载(从 Chocolatey)并从原始网站重新安装 MinGW,但无济于事。 如果您能帮助我了解问题所在以及如何解决,我将不胜感激。
PS要解决上述问题,应使用以下命令:
cmake -DCMAKE_C_COMPILER=C:/MinGW/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/MinGW/bin/g++.exe -DCMAKE_Fortran_COMPILER=C:/MinGW/bin/gfortran.exe -DCMAKE_MAKE_PROGRAM=C:/MinGW/bin/mingw32-make.exe .. -G "MinGW Makefiles"
但是还有缺少的 BLAS 问题。 我正在努力解决。 这使用 MSYS2
要在 Windows 上构建 Elmer,您需要MSYS ,正如您所指出的(有关无效项目的 Visual Studio 错误是因为在 cmd.exe 中运行时生成了 Intel Fortran Visual Studio 项目,但未安装 Intel Fortran Visual Studio 扩展)。 使用pacman安装 Elmer 的 MSYS 依赖项: cmake 、 openblas 、 qt5 、 qwt-qt5和nsis (截至提交442ea2000f87 )。 有关安装这些依赖项所需的所有命令,请参阅此脚本。 您还可以在 MSYS 中运行该脚本来安装所有必需的依赖项,构建 Elmer,并使用可执行的 Elmer 二进制文件创建本地 Elmer 安装目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.