# problem using gfortran with MSVC 18

**URL:** https://discourse.cmake.org/t/problem-using-gfortran-with-msvc-18/15608
**Category:** Usage
**Tags:** lang:fortran
**Created:** [April 19, 2026, 7:59pm UTC](https://discourse.cmake.org/t/problem-using-gfortran-with-msvc-18/15608 "2026-04-19T19:59:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![BillG](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@BillG](https://discourse.cmake.org/u/BillG)
#### Post date: [April 19, 2026, 7:59pm UTC](https://discourse.cmake.org/t/problem-using-gfortran-with-msvc-18/15608/1 "2026-04-19T19:59:38Z")

</div>

I am trying to use cmake 4.3.0 to build a project with  
-G “Visual Studio 18 2026”  
and gfortran.

My CMakeLists.txt file includes:

set(CMake\_ARCHIVE\_OUTPUT\_DIRECTORY ./my\_fortran\_lib)  
set(CMake\_RUNTIME\_OUTPUT\_DIRECTORY ./my\_fortran\_lib)  
cmake\_add\_fortran\_subdirectory(my\_fortran\_lib NO\_EXTERNAL\_INSTALL  
PROJECT my\_fortran\_lib  
ARCHIVE\_DIR ${CMake\_ARCHIVE\_OUTPUT\_DIRECTORY}  
RUNTIME\_DIR ${CMake\_RUNTIME\_OUTPUT\_DIRECTORY}  
LINK\_LIBRARIES # link interface libraries  
LINK\_LIBS my\_fortran\_lib  
LIBRARIES my\_fortran\_lib  
)

When I run cmake I get the errors below:

* * *

– Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.26200.  
– The Fortran compiler identification is unknown  
– Detecting Fortran compiler ABI info  
– Detecting Fortran compiler ABI info - failed  
– Check for working Fortran compiler: C:/msys64/mingw64/bin/gfortran.exe  
– Check for working Fortran compiler: C:/msys64/mingw64/bin/gfortran.exe - broken  
CMake Error at C:/PROGRA~1/CMake/share/cmake-4.3/Modules/CMakeTestFortranCompiler.cmake:59 (message):  
The Fortran compiler

```auto
"C:/msys64/mingw64/bin/gfortran.exe"

```

is not able to compile a simple test program.

It fails with the following output:

```auto
Change Dir: 'D:/projects/fortran_cpp_cmake_test_visual_studio/CMakeFiles/CMakeScratch/TryCompile-58lv4u'

Run Build Command(s): "C:/Program Files/Microsoft Visual Studio/18/Community/Common7/IDE/devenv.com" D:/projects/fortran_cpp_cmake_test_visual_studio/CMakeFiles/CMakeScratch/TryCompile-58lv4u/CMAKE_TRY_COMPILE.slnx /build Debug /project cmTC_a296f

Microsoft Visual Studio Version 18.5.0.
Copyright (C) Microsoft Corp. All rights reserved.

The operation could not be completed. The parameter is incorrect.

```

* * *

Unfortunately, the directory TryCompile-58lv4u does not exist.
