CMake cannot find ifconsol.lib

Hi all,
I’ve been trying for days in any possible way, but after the install of the new Intel oneApi HPC I’m not able to compile any Fortran (mixed C/Fortran) code from CMake.

I’m launching CMake by command prompt after having called the bat scripts from Intel (setvars) and from VS (vcvars) to have PATH in a proper state. IFort is found,

What happens is that I get “No CMAKE_Fortran_COMPILER could be found” and the CMakeError.log tells that CompilerIdFortran failed because of
LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'

I tried also to put the folder containing the proper ifconsol.lib directory in PATH and also in LIBPATH and in LIB (yes, I know I’m in Windows, but I tried) but I always hit the same issue.

I’m really going crazy.

Thanks in advance for any help.


(cannot add attachment because I’m a new user)

Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Build flags: 
Id flags: 
The output was:
Microsoft Visual Studio 2019 Version 16.8.4.
Copyright (C) Microsoft Corp. All rights reserved.
Package 'IFLangServicePackage' failed to load.
Package 'IFLangServicePackage' failed to load.
1>------ Build started: Project: CompilerIdFortran, Configuration: Debug x64 ------
1>Compiling with Intel© Fortran Compiler Classic 2021.1.1 [Intel(R) 64]...
1>Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.1 Build 20201112_000000
1>Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.
1>Microsoft (R) Incremental Linker Version 14.28.29336.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
1>LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'
1>Build log written to  "file://C:\workspace\libraries\MUMPS_5.1.2_build\CMakeFiles\3.19.3\CompilerIdFortran\Debug\BuildLog.htm"
1>CompilerIdFortran - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

It sounds like something is doing (a Fortran equivalent of) #pragma comment to do “autolinking”. This still needs the library directory added, but I’m not familiar.


After days of struggling I understood what was going on…
Cmake tries to compile the CMakeFortranCompilerId that is inside <CMAKE_BINARY_DIR>\CMakeFiles\<CMakeVersion>\CompilerIdFortran, but what I didn’t know is that is not trying to compile it through a simple command line compilation, but through Visual Studio.

In fact I was perfectly able to compile the CMakeFortranCompilerId.f manually from command line, but I wasn’t when I opened the CompilerIdFortran.vfproj Visual Studio project.

The problem is caused by a wrong Visual Studio variable macro $(IFortInstallDir) that was pointing to C:\Program Files (x86)\Intel\Compiler\12.0 instead of %IFORT_COMPILER19% that for me is C:\Program Files (x86)\Intel\oneAPI\compiler\2021.1.1\windows\;

To solve the issue you need to go inside Visual Studio>Tools>Options>Intel Compiler and Libraries>IFORT Intel Fortran Classic>Compilers>x64 and in the forms Executables, Includes, Libraries look for any instance of $(IFortInstallDir) and replace it with $(IFORT_COMPILER19).

On the contrary, if you use the new IFX instead of the standard IFORT, it seems that the paths are set correctly.

I don’t know if the $(IFortInstallDir) macro can be changed directly (I didn’t find any hint online)
I will invite Intel to double check their Visual Studio integration.

Ah, oneAPI had some fixes that were made in 3.19.2 (for Windows; Linux is 3.19.3). Does using those versions work? See this thread.

It’s nice to know that I’m not the only one to have had issues with the new oneApi, however I didn’t find the same issue in my case.
I’m up to date with CMake 3.19.4 and oneApi HPC 2682 and oneApi Base 2664.

And BTW, the reporter says:

I frequently link statically build libraries together, as linking dynamic libraries between C and Fortran is more complicated on Windows with Intel compilers

Guess, what I’m doing…

And actually I didn’t solve my problem yet. With CMake it’s now working properly but I’m encountering a lot of errors in the compilation (warnings of bad preprocessor directives, errors in finding symbols, ifx that was not found because actually the default path points to the ifort directory instead).

Anyway, CMake is now able to compile at least basic test files so I think it’s now totally on Intel+VS.

Please file an issue to track this (even if it’s not our problem, it’d be nice to have a single point for anyone else encountering the problem to add information in case we can do something eventually).

Do you mean an issue on Kitware/CMake GitHub or are you talking about Intel forum?

Ah sorry, on CMake’s issue tracker.

I just realized that a similar thread was already there. I don’t know why I didn’t find it before… and I was exactly looking at GitLab…

I added a comment to this thread since it matches the problem that I had.

I could also open a new one if you think it’s better