Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29030 Discussions

Ifort and Cmake, issues including compiler paths

BWunderlich
Beginner
1,113 Views

Dear community, 

 

We struggled to migrate a Win32  C++/Fortran mixed language application to VS 2022 MSVC / oneAPI classic ifort using a cmake build system.

 

To be more precise, we used

Intel® oneAPI standalone component installation files

Intel Fortran Compiler Classic and Intel Fortran Compiler for Windows*

It was difficult to figure out how to make cmake use this compiler in the first place. The solution we found after some hours of research was to initialize the environment variables as follows:

 

"C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat" ia32

"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"  ia32

set FC=ifort

 

However, when doing that, we encountered link errors when trying to link the basic runtime library

 

        target_link_libraries(SMILE PUBLIC libifcore.lib)

 

C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\compiler\lib\intel64_win\libifcore.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'

C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\compiler\lib\intel64_win\ifmodintr.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'

 

This error can be avoided by explicitly specifying the library search path for the x86 version:

 

        target_link_directories(SMILE_Solver_static PUBLIC

            "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.1.0/windows/compiler/lib/ia32"

        )

 

However, this does not feel right – why does this have to be specified explicitly after the environment variables have been set explicitly for the x86 architecture?

 

Furthermore, the only cmake generator that seems to be able to build mixed C++ / FORTRAN mixed language projects seems to be “NMake Generator” – is that right? This generator does not allow for multi-config builds, right?

 

It would be great if VS2022’s cmake integration could be used for mixed language projects (which is possible with mingw-gcc), but we did not manage to use it. That makes debugging somewhat difficult.

 

Regards

Ingo and Bernd

0 Kudos
1 Reply
Barbara_P_Intel
Employee
1,053 Views

Seems like your environment is not setup correctly.

Try setting up your environment in a command prompt window using only:

"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"  ia32

That link error is showing that you are trying to link a 64-bit library (x64) with your 32-bit application.

 

0 Kudos
Reply