1

Following this post, I'm trying to compile Elmer FEM on Windows using the MinGW compilers. However when running the

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 ..

command in the build folder I get the error:

-- 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

from here I tried adding the

set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")

to the CmakeLists.txt file, running the cmd as admin from here, and from here tried uninstalling (from Chocolatey) and re-installing MinGW from the original website with no avail. I would appreciate it if you could help me know what is the problem and how I can solve it.

P.S. To solve the above issue one shoudl use the command:

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"

But then there is the missing BLAS issue. I'm trying to solve. this using MSYS2

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
  • 1
    A bit of a wild guess, why setting the compiler explicitly isn't `C:\MinGW\bin` in your path (beforte the Visual Studio stuff)? And why didn't you specify the generator? Maybe `cmake -G "MinGW Makefiles" ..` will work. For the options on CMake see `cmake --help`. – albert Mar 12 '20 at 18:03
  • 1
    @Foad: I ran into the same problem. I will post a solution if I can fix it. – Axion004 Jul 19 '20 at 23:38

1 Answers1

1

To build Elmer on Windows, you need MSYS as you pointed out (the Visual Studio error about an invalid project is because an Intel Fortran Visual Studio project was generated when running in cmd.exe but the Intel Fortran Visual Studio extension is not installed). Use pacman to install Elmer's MSYS dependencies: cmake, openblas, qt5, qwt-qt5, and nsis (as of commit 442ea2000f87). See this script for all the commands required to install these dependencies. You can also run that script in MSYS to install all the required dependencies, build Elmer, and create a local Elmer install directory with executable Elmer binaries.