# How to use Intel MPI library with cmake on Windows (VS2017)?

**URL:** https://discourse.cmake.org/t/how-to-use-intel-mpi-library-with-cmake-on-windows-vs2017/5270
**Category:** Usage
**Tags:** os:windows, gen:vs
**Created:** [March 22, 2022, 9:10pm UTC](https://discourse.cmake.org/t/how-to-use-intel-mpi-library-with-cmake-on-windows-vs2017/5270 "2022-03-22T21:10:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![AllenZhao](https://discourse.cmake.org/user_avatar/discourse.cmake.org/allenzhao/32/2279_2.png) [@AllenZhao](https://discourse.cmake.org/u/AllenZhao)
#### Post date: [March 22, 2022, 9:10pm UTC](https://discourse.cmake.org/t/how-to-use-intel-mpi-library-with-cmake-on-windows-vs2017/5270/1 "2022-03-22T21:10:23Z")

</div>

I have a mixed language MPI package that uses cmake on linux. While on Windows, I am using Visual Studio 2017. The C/C++ compiler will be the Microsoft cl, and Fortran compiler will be the Intel ifort 2017 (hosted in VS 2017). I know Microsoft has MPI msi, and Intel has its own MPI Library, is it possible to make it work with cmake?

Here is what I did, but cmake does not recognize either C or Fortran MPI component:

1. Within VS2017, I select the ifort 2019.1.3.311 as Intel fortran compiler
2. The Intel MPI library is installed in C:\Program Files (x86)\IntelSWTools\mpi\2019.10.321\intel64
3. I set MPI\_HOME to above installed location, and launch cmake-gui.exe

Here is the error:  
Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19043.

The C compiler identification is MSVC 19.16.27034.0

The Fortran compiler identification is Intel 19.1.3.20201010

Detecting C compiler ABI info

Detecting C compiler ABI info - done

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - skipped

Detecting C compile features

Detecting C compile features - done

Detecting Fortran compiler ABI info

Detecting Fortran compiler ABI info - done

Determine Intel Fortran Compiler Implicit Link Path

Determine Intel Fortran Compiler Implicit Link Path - done

Check for working Fortran compiler: C:/Program Files (x86)/IntelSWTools/compilers\_and\_libraries\_2020.4.311/windows/bin/intel64/ifort.exe - skipped

Could NOT find MPI\_C (missing: MPI\_C\_WORKS)

Could NOT find MPI\_Fortran (missing: MPI\_Fortran\_WORKS)

CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):  
Could NOT find MPI (missing: MPI\_C\_FOUND MPI\_Fortran\_FOUND C Fortran)  
Call Stack (most recent call first):  
C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (\_FPHSA\_FAILURE\_MESSAGE)  
C:/Program Files/CMake/share/cmake-3.23/Modules/FindMPI.cmake:1830 (find\_package\_handle\_standard\_args)  
CMakeLists.txt:21 (find\_package)

Configuring incomplete, errors occurred!

Obviously, I am missing something, right?

---

<div class="post-metadata">

### Author: ![AllenZhao](https://discourse.cmake.org/user_avatar/discourse.cmake.org/allenzhao/32/2279_2.png) [@AllenZhao](https://discourse.cmake.org/u/AllenZhao)
#### Post date: [March 22, 2022, 9:21pm UTC](https://discourse.cmake.org/t/how-to-use-intel-mpi-library-with-cmake-on-windows-vs2017/5270/2 "2022-03-22T21:21:04Z")

</div>

Actually, with Intel MPI library, if I load the var first:  
C:\Users\allen\Desktop\mumps-main\>“C:\Program Files (x86)\IntelSWTools\mpi\2019.10.321\intel64\bin\mpivars.bat”

Intel(R) MPI Library 2019 Update 10 for Windows\* Target Build Environment for Intel(R) 64 applications  
Copyright 2007-2021 Intel Corporation.

C:\Users\allen\Desktop\mumps-fetchcontent-main\>cmake . -G “Visual Studio 15 2017 Win64”  
– Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19043.  
– The C compiler identification is MSVC 19.16.27034.0  
– The Fortran compiler identification is Intel 19.1.3.20201010  
– Detecting C compiler ABI info  
– Detecting C compiler ABI info - done  
– Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe - skipped  
– Detecting C compile features  
– Detecting C compile features - done  
– Detecting Fortran compiler ABI info  
– Detecting Fortran compiler ABI info - done  
– Determine Intel Fortran Compiler Implicit Link Path  
– Determine Intel Fortran Compiler Implicit Link Path - done  
– Check for working Fortran compiler: C:/Program Files (x86)/IntelSWTools/compilers\_and\_libraries\_2020.4.311/windows/bin/intel64/ifort.exe - skipped  
– Found MPI\_C: C:/Program Files (x86)/IntelSWTools/mpi/2019.10.321/intel64/lib/release/impi.lib (found version “3.1”)  
– Found MPI\_Fortran: C:/Program Files (x86)/IntelSWTools/mpi/2019.10.321/intel64/lib/release/impi.lib (found version “3.1”)  
– Found MPI: TRUE (found version “3.1”) found components: C Fortran  
– checking that C and Fortran compilers can link  
– checking that C and Fortran compilers can link - OK

Then both C and Fortran MPI will be ok, but it is just that this MPI\_C is using Intel’s C compiler, not the Microsoft C compiler. (Our site does not use Intel C compiler, except me). Any pointer to de-commision the intel C?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 29, 2022, 1:01pm UTC](https://discourse.cmake.org/t/how-to-use-intel-mpi-library-with-cmake-on-windows-vs2017/5270/3 "2022-03-29T13:01:24Z")

</div>

> [@AllenZhao](#):
>
> but it is just that this MPI\_C is using Intel’s C compiler

Where do you see this? It looks to me like C code will use MSVC in the output you provided. Are you referring to detection? If so, I don’t think that affects the actual builds.

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [May 5, 2023, 7:09pm UTC](https://discourse.cmake.org/t/how-to-use-intel-mpi-library-with-cmake-on-windows-vs2017/5270/4 "2023-05-05T19:09:49Z")

</div>

I interpret this result as MSVC using the Intel MPI library for the C language. I am the author of the MUMPS CMake scripts you’re using. Because the numerical core of MUMPS is written in Fortran, building MUMPS requires an ABI-compatible Fortran compiler (that check is written by me) even if your project is primarily in C.
